html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2b5d2e;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* Score bug, top left like a TV broadcast. */
#scorebug {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 8px);
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
#scorebug > div { padding: 6px 10px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#scorebug .lg { display: flex; margin: -2px -2px -2px -4px; }
#scorebug .pts { font-size: 20px; min-width: 22px; text-align: right; }
#scorebug .team.poss .nm::after { content: " \25C0"; font-size: 11px; color: #ffe14d; }
#sb-home { background: #4a2810; }
#sb-away { background: #0d2a52; }
#sb-clock { background: #111; }
#sb-down { background: #222; color: #ffe14d; }

#banner {
  position: fixed;
  top: 20%;
  left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.2s, transform 0.2s;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}
#banner.show { opacity: 1; transform: scale(1); }
#banner b { display: block; font-size: 44px; font-weight: 900; letter-spacing: 1px; }
#banner small { display: block; font-size: 19px; font-weight: 700; margin-top: 2px; }
#banner.score b { color: #ffe14d; }
#banner.bad b { color: #ff8a7a; }
#banner.good b { color: #9dff8a; }

/* Play call menu, bottom centre. */
#menu {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%);
  background: rgba(10, 14, 10, 0.78);
  border-radius: 14px;
  padding: 10px 12px 12px;
  text-align: center;
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}
#menu-title { font-weight: 800; font-size: 15px; margin-bottom: 8px; color: #ffe14d; }
#menu-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#menu button, #start button {
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: #3b7a3e;
  cursor: pointer;
  min-width: 96px;
}
#menu button.special { background: #6b5a2a; }
#menu-buttons { flex-direction: column; align-items: center; }
#menu .tabs { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
#menu .plays {
  display: flex; gap: 8px; overflow-x: auto; max-width: calc(100vw - 48px);
  padding: 2px 2px 4px; touch-action: pan-x; scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
#menu button.card {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 5px 5px 7px; min-width: 0; background: #1b2b1b; border: 2px solid #3b7a3e; font-size: 13px;
}
#menu button.card svg { display: block; width: 150px; height: 108px; }
#menu button.card:hover { border-color: #ffe14d; }
#menu .tabs { gap: 6px; }
#menu button.tab { background: #2a3a2a; min-width: 74px; padding: 6px 12px; font-size: 13px; }
#menu button.tab.on { background: #ffe14d; color: #1a1a1a; }
#menu button:active, #start button:active { transform: scale(0.96); }

#targets { position: fixed; inset: 0; pointer-events: none; }
#targets button {
  position: absolute;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #e8a317;
  color: #1a1a1a;
  font: 900 22px system-ui, sans-serif;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
#ctrl-name {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 50px);
  left: calc(env(safe-area-inset-left) + 10px);
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Touch controls: the stick appears where the left thumb lands. */
#stick {
  position: fixed;
  width: 120px; height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.15);
  pointer-events: none;
  display: none;
}
#knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}
.pad {
  position: fixed;
  right: calc(env(safe-area-inset-right) + 22px);
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: rgba(200, 60, 40, 0.75);
  color: #fff;
  font: 900 15px system-ui, sans-serif;
  display: none;
}
.pad.small {
  width: 70px; height: 70px;
  right: calc(env(safe-area-inset-right) + 130px);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  background: rgba(40, 90, 200, 0.75);
  font-size: 12px;
}
.pad.on { display: block; }

#start {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(20, 50, 20, 0.82), rgba(5, 15, 5, 0.94));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  text-align: center;
  overflow-y: auto;
}
#start h1 { margin: 0; font-size: clamp(32px, 8vw, 60px); font-weight: 900; letter-spacing: 2px; color: #ffe14d;
  text-shadow: 0 4px 0 #4a2810; }
#start .sub { margin: 4px 0 18px; font-weight: 600; opacity: 0.9; }
#start .pick { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
#start .pick button { min-width: 180px; padding: 16px 18px; font-size: 15px; font-weight: 600; line-height: 1.4; }
#start .pick b { font-size: 19px; }
#start .bears { background: #f29a10; color: #2a1608; }
#start .sharks { background: #0d2a52; border: 2px solid #12b5ae !important; }
#start .ghost { margin-top: 14px; background: transparent; border: 2px solid rgba(255, 255, 255, 0.5); }
#start .how { max-width: 560px; font-size: 14px; line-height: 1.45; opacity: 0.85; margin-top: 18px; }

#mute {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  right: calc(env(safe-area-inset-right) + 8px);
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#pause-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  right: calc(env(safe-area-inset-right) + 60px);
  width: 44px; height: 44px;
  border-radius: 50%; border: 0; padding: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
#start .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Pause and options panels. */
.panel {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(5, 15, 5, 0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; box-sizing: border-box; overflow-y: auto;
}
.panel h2 { margin: 0 0 6px; color: #ffe14d; font-size: 30px; font-weight: 900; letter-spacing: 2px; }
.panel button {
  font: inherit; font-weight: 800; font-size: 16px; color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; background: #3b7a3e; min-width: 200px; cursor: pointer;
}
.panel button.ghost { background: transparent; border: 2px solid rgba(255, 255, 255, 0.5); }
#option-rows { display: grid; grid-template-columns: auto auto; gap: 10px 14px; align-items: center; max-width: 640px; }
#option-rows label { font-weight: 700; text-align: right; }
#option-rows .choices { display: flex; flex-wrap: wrap; gap: 6px; }
#option-rows .choices button { min-width: 0; padding: 7px 11px; font-size: 14px; background: #2a3a2a; }
#option-rows .choices button.on { background: #ffe14d; color: #1a1a1a; }
.panel .note { font-size: 13px; opacity: 0.8; margin: 0; min-height: 1em; text-align: center; }
@media (max-width: 560px) {
  #option-rows { grid-template-columns: 1fr; }
  #option-rows label { text-align: left; }
}
@media (max-height: 430px) {
  .panel { justify-content: flex-start; gap: 6px; }
  .panel h2 { font-size: 22px; }
  #option-rows { gap: 5px 12px; }
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  background: #2b5d2e;
}

@media (max-height: 430px) {
  #menu button.card svg { width: 112px; height: 81px; }
  #menu button.card { font-size: 12px; padding: 4px 4px 5px; }
  #menu-title { margin-bottom: 4px; font-size: 13px; }
  #banner b { font-size: 34px; }
  #banner { top: 16%; }
  #menu button { padding: 9px 11px; min-width: 84px; font-size: 14px; }
  #menu { padding: 7px 9px 9px; }
}
@media (max-width: 500px) {
  #scorebug { font-size: 12px; }
  #scorebug > div { padding: 5px 7px; gap: 5px; }
  #scorebug .pts { font-size: 16px; min-width: 16px; }
  #sb-down { display: none !important; }
}
