:root {
  --bg: #fff3e2;
  --panel: #ffffff;
  --accent: #ff7a3d;
  --accent-strong: #f2540c;
  --gold: #ffb703;
  --text: #3a2b21;
  --muted: #a8968a;
  --line: #f0c9a8;
  --line-decided: #ff7a3d;
  --win: #2fa84f;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  height: 100%;
}

.app-frame {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 183, 3, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(255, 122, 61, 0.2) 0%, transparent 45%),
    var(--bg);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar h1 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  text-align: center;
  letter-spacing: 0.02em;
}

.icon-btn {
  background: linear-gradient(180deg, #ffffff, #fff0de);
  border: 1px solid var(--line);
  color: var(--accent-strong);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 #e8b98a, 0 3px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #e8b98a, 0 1px 2px rgba(0, 0, 0, 0.08);
}

.icon-btn--ghost {
  visibility: hidden;
}

#screens {
  flex: 1;
  padding: 14px 14px 28px;
}

.panel {
  display: none;
}

.panel--active {
  display: block;
}

.round-label {
  text-align: center;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.85rem;
  margin: 4px 0 2px;
  letter-spacing: 0.04em;
}

/* ---------- top (splash) screen ---------- */

.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  min-height: 100vh;
  border: none;
  margin: 0;
  padding: 24px;
  cursor: pointer;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 183, 3, 0.35) 0%, transparent 50%),
    radial-gradient(circle at 80% 15%, rgba(255, 122, 61, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(255, 122, 61, 0.25) 0%, transparent 55%),
    var(--bg);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.splash-emojis {
  display: flex;
  gap: 14px;
  font-size: 2.1rem;
}

.splash-emojis span {
  display: inline-block;
  animation: float 2.4s ease-in-out infinite;
}

.splash-emojis span:nth-child(2) { animation-delay: 0.15s; }
.splash-emojis span:nth-child(3) { animation-delay: 0.3s; }
.splash-emojis span:nth-child(4) { animation-delay: 0.45s; }
.splash-emojis span:nth-child(5) { animation-delay: 0.6s; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.splash-title {
  margin: 0;
  text-align: center;
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--accent-strong);
  text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(242, 84, 12, 0.25);
  letter-spacing: 0.02em;
}

.splash-tap {
  margin: 10px 0 0;
  padding: 12px 40px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(180deg, #ffb15f, var(--accent-strong));
  border-radius: 999px;
  box-shadow: 0 4px 0 #c73f00, 0 8px 18px rgba(242, 84, 12, 0.35);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ---------- bracket tree (baseball大会と同じ構造のSVG連結線方式) ---------- */

.bracket-tree-wrap {
  overflow-x: auto;
  width: 100%;
}

.bracket-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 14px;
  margin: 6px 0;
  width: 100%;
}

.bracket-lines {
  /* JS側のTREE_W/TREE_Hと同じ実ピクセル値にする(等倍表示にして線の太さ・輪郭を崩さない) */
  width: 380px;
  height: 200px;
  display: block;
  overflow: visible;
}

.bracket-line {
  stroke: var(--line);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.bracket-line--decided {
  stroke: var(--line-decided);
  stroke-width: 3.5;
  stroke-linecap: round;
}

.bracket-leaves-row {
  display: flex;
  gap: 4px;
  width: 380px;
}

.bracket-team {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 2px;
  width: 44px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.64rem;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  min-height: 64px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.bracket-team--pending {
  color: var(--muted);
  font-size: 0.8rem;
}

.bracket-team--out {
  opacity: 0.35;
}

.bracket-team__emoji {
  font-size: 1.1rem;
}

.bracket-team__name {
  font-weight: 600;
}

/* ---------- next match card ---------- */

.next-match {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.next-match h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-align: center;
  color: var(--accent-strong);
}

.next-match__hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 8px 0;
}

.vs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vs-divider {
  font-weight: 800;
  color: var(--accent);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.vs-card {
  flex: 1;
  background: linear-gradient(180deg, #ffffff, #fff7ee);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  box-shadow: 0 3px 0 var(--line), 0 5px 10px rgba(0, 0, 0, 0.06);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.vs-card:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--line), 0 2px 4px rgba(0, 0, 0, 0.06);
}

.vs-card:hover {
  border-color: var(--accent);
}

.vs-card__emoji {
  font-size: 1.8rem;
}

.vs-card__name {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

/* ---------- champion screen ---------- */

#screen-champion {
  text-align: center;
  padding-top: 12px;
}

.champion-burst {
  font-size: 3.4rem;
  animation: pop 0.5s ease;
}

@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.champion-title {
  margin: 4px 0 2px;
  font-size: 1.3rem;
  color: var(--accent-strong);
}

.champion-sub {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(180deg, #ffb15f, var(--accent-strong));
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c73f00, 0 6px 14px rgba(242, 84, 12, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c73f00, 0 2px 6px rgba(242, 84, 12, 0.25);
}
