:root {
  --bg: #07140d;
  --pitch: #1a7a3c;
  --line: rgba(255, 255, 255, 0.85);
  --accent: #f5c518;
  --panel: rgba(8, 20, 14, 0.92);
  --text: #f2fff6;
  --muted: #9ec9ad;
  --danger: #ff5c5c;
  --ok: #3dff9a;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: fixed;
  inset: 0;
  width: 100%;
}

#wrap {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  margin: 0 auto;
  background: #0a1f12;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  left: 0; right: 0; top: 0;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  z-index: 2;
}
#hudTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
#scoreline { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; flex: 1; min-width: 0; }
#hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

.mute-btn {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.4);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  display: grid;
  place-items: center;
}
.mute-btn:active { transform: scale(0.94); }

.panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(20px + var(--safe));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.panel.hidden { display: none; }

#titleArt {
  width: min(72vw, 260px);
  height: auto;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  margin-bottom: 12px;
  object-fit: cover;
  max-height: 28vh;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.06em;
  color: var(--accent);
}
h2 { margin: 12px 0 8px; font-size: 24px; color: var(--accent); }
.sub { margin: 6px 0 14px; color: var(--muted); text-align: center; }
.tiny { font-size: 11px; color: var(--muted); margin-top: 12px; }

.result-flag {
  font-size: 56px;
  line-height: 1;
  margin-top: 12px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.35));
}
.result-flag[hidden] { display: none; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 16px;
}

.team-btn {
  appearance: none;
  border: 2px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 10px 4px 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  transition: border-color .15s, transform .1s, background .15s;
}
.team-btn .flag { font-size: 22px; line-height: 1; }
.team-btn.selected {
  border-color: var(--accent);
  background: rgba(245, 197, 24, 0.15);
  transform: scale(1.04);
}
.team-btn:active { transform: scale(0.97); }

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: min(100%, 280px);
  margin-top: 8px;
}
.btn.primary {
  background: linear-gradient(180deg, #ffe066, #f5c518);
  color: #1a1200;
}
.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,.2);
}
#resultBody { text-align: center; color: var(--muted); max-width: 280px; line-height: 1.4; }
