:root {
  --bg: #0c121c;
  --panel: rgba(20, 29, 43, 0.88);
  --panel-border: rgba(255, 255, 255, 0.07);
  --text: #e2e8f0;
  --muted: #8b9bb4;
  --you: #38bdf8;
  --ai: #f47286;
  --accent: #34d399;
  --accent-hover: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #152033 0%, var(--bg) 70%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 10px 16px;
}

.app-shell {
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-top {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent), #10b981);
  color: #052e16;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 7px;
}

.brand-logo {
  border-radius: 6px;
  display: block;
}

.brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(6, 10, 20, 0.55);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 12px;
}

.team {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.team .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.team-you .dot {
  background: var(--you);
  box-shadow: 0 0 8px var(--you);
}

.team-ai .dot {
  background: var(--ai);
  box-shadow: 0 0 8px var(--ai);
}

.team-name {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.score {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
}

.clock-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 10px;
  border-left: 1px solid var(--panel-border);
  border-right: 1px solid var(--panel-border);
}

#match-clock {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.match-state {
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.82rem;
  color: var(--muted);
}

.control-pill.hidden {
  display: none;
}

.control-pill select {
  background: transparent;
  color: var(--text);
  border: none;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.control-pill select option {
  background: #131d31;
  color: var(--text);
}

.btn {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn:active {
  transform: scale(0.97);
}

.btn-toggle.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.55);
  color: #bae6fd;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #052e16;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-large {
  padding: 11px 26px;
  font-size: 1rem;
  border-radius: 10px;
}

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pitch-frame {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  background: #1d5731;
  flex-shrink: 0;
  width: min(660px, 92vw, calc((100vh - 140px) * 660 / 700));
  min-width: 280px;
  aspect-ratio: 660 / 700;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 22, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  background: rgba(19, 29, 49, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 26px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  font-size: 1.55rem;
  margin-bottom: 6px;
}

.overlay-card p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.overlay-stats {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.5;
}

.overlay-stats.hidden {
  display: none;
}

.online-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.online-divider {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.online-setup {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.join-row {
  display: flex;
  gap: 6px;
}

.join-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 0.84rem;
  text-transform: uppercase;
  outline: none;
}

.join-row input:focus {
  border-color: var(--you);
}

.btn-online {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

.btn-online:hover {
  background: rgba(56, 189, 248, 0.28);
}

.online-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.online-status.hidden,
.room-code-row.hidden {
  display: none;
}

.room-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 6px 10px;
}

.room-code-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.06em;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.76rem;
}

.tutorial-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 12px;
  padding: 10px 14px;
  z-index: 20;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.tutorial-banner.hidden {
  display: none;
}

.tutorial-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.tutorial-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #38bdf8;
}

.tutorial-banner p {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.35;
}

.brand-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.brand-footer strong {
  color: var(--text);
  font-weight: 600;
}

.brand-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-links a {
  color: var(--you);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.brand-links a:hover {
  opacity: 1;
  text-decoration: underline;
}

.controls-panel {
  position: fixed;
  top: 76px;
  right: 18px;
  z-index: 40;
  background: rgba(19, 29, 49, 0.97);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 16px;
  width: 290px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.controls-panel.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px);
}

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-icon {
  padding: 3px 8px;
  font-size: 0.85rem;
  line-height: 1.2;
}

.drawer-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-row {
  justify-content: space-between;
  padding: 7px 10px;
}

.drawer-btn {
  width: 100%;
  text-align: left;
}

.drawer-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 2px 0;
}

.controls-panel h3 {
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.controls-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.86rem;
}

.controls-panel li {
  display: block;
  line-height: 1.55;
}

.controls-panel li span {
  color: var(--muted);
}

kbd {
  display: inline-block;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  color: var(--text);
  margin-right: 3px;
}

.tip-box {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #bbf7d0;
}

@media (max-width: 820px) {
  .stage {
    flex-direction: column;
    align-items: center;
  }

  .controls-panel {
    width: min(460px, 92vw);
  }
}
