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

html, body {
  overscroll-behavior: none;
  height: 100%;
  overflow: hidden;        /* never scroll — the game owns the whole viewport */
  touch-action: none;      /* no pan / pinch-zoom / pull-to-refresh on mobile */
}

body {
  background: #0d1321;
  background-image:
    radial-gradient(circle at 50% 0%, #16203a 0%, #0d1321 60%);
  color: #eef2f7;
  font-family: "Press Start 2P", monospace;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  /* Stop long-press selection / callouts / double-tap zoom on touch */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#wrap {
  width: 980px;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

header { flex: 0 0 auto; }

/* Fills the space between header and footer; centers the aspect-fit rink. */
#stageWrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

header h1 {
  text-align: center;
  letter-spacing: 6px;
  font-size: 22px;
  color: #9cc3ff;
  text-shadow: 3px 3px 0 #1d3d8f, 0 0 18px rgba(80, 140, 255, 0.5);
  margin-bottom: 10px;
}

header h1 .bit {
  font-size: 10px;
  color: #ffd866;
  letter-spacing: 2px;
  vertical-align: super;
  text-shadow: 2px 2px 0 #8f5a18;
}

#hud {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  font-size: 22px;
  margin-bottom: 8px;
}

.score { display: flex; gap: 10px; align-items: center; }
.score .team-name { font-size: 9px; letter-spacing: 2px; opacity: 0.8; }
.score.home span:last-child, .score.away span:first-child { min-width: 36px; text-align: center; }
.score.home { color: #6ea8ff; text-shadow: 2px 2px 0 #1d3d8f; }
.score.away { color: #ff7a6e; text-shadow: 2px 2px 0 #8f2018; }

#clock {
  background: #060a14;
  border: 3px solid #2a3a5c;
  padding: 6px 14px;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  color: #ffd866;
  image-rendering: pixelated;
}

#hitMeter {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 8px;
  letter-spacing: 2px;
  color: #ffb35c;
  margin-bottom: 8px;
}

#hitPips { display: flex; gap: 6px; }
.pip {
  width: 18px; height: 10px;
  border: 2px solid #ffb35c;
  background: transparent;
  transition: background 0.15s;
}
.pip.filled { background: #ffb35c; box-shadow: 0 0 8px rgba(255, 179, 92, 0.7); }

/* The rink keeps a fixed 480:260 aspect and shrinks to fit whatever space is
   left after the header — always fully visible, never cut off. fitStage() in
   game.js sets the exact px size; these are the pre-JS fallback. */
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 480 / 260;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid #2a3a5c;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

/* CRT scanlines over the ice */
#scanlines {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(10, 14, 26, 0.16) 3px,
    rgba(10, 14, 26, 0.16) 4px
  );
  mix-blend-mode: multiply;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 24, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  text-align: center;
  padding: 20px;
  z-index: 2;
  overflow-y: auto;   /* a tall menu scrolls inside the rink, never the page */
}

.overlay h2 {
  font-size: 30px;
  letter-spacing: 4px;
  color: #9cc3ff;
  text-shadow: 3px 3px 0 #1d3d8f;
}
.overlay .tagline { color: #c9d6ea; font-size: 10px; line-height: 1.8; }

.rules {
  list-style: none;
  line-height: 2.4;
  font-size: 9px;
  color: #c9d6ea;
  text-align: left;
}
.rules b { color: #ffd866; }

/* Quick Play settings */
.settings { display: flex; flex-direction: column; gap: 9px; }
.setting-row {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; flex-wrap: wrap;
}
.setting-label {
  font-size: 8px; letter-spacing: 1px; color: #8fb4ee;
  min-width: 84px; text-align: right;
}
.chips { display: flex; gap: 6px; }
.chip {
  font-family: "Press Start 2P", monospace; font-size: 9px; letter-spacing: 1px;
  padding: 8px 11px; border: 2px solid #2d4a86; background: #0f1c36;
  color: #9fb3d6; cursor: pointer; box-shadow: none;
}
.chip:hover { background: #16264a; transform: none; box-shadow: none; }
.chip:active { transform: translate(1px, 1px); box-shadow: none; }
.chip.selected { border-color: #ffd866; background: #2a2410; color: #ffd866; }

/* Start menu */
.menu-screen { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.menu-btn { min-width: 280px; }
.menu-actions { display: flex; gap: 12px; align-items: center; }
.back-btn {
  font-size: 11px; padding: 12px 18px;
  border-color: #45597f; background: #0f1c36; color: #9fb3d6;
}
.tagline.big { color: #9cc3ff; font-size: 14px; letter-spacing: 2px; }
.soon {
  color: #ffd866; font-size: 11px; letter-spacing: 3px;
  border: 2px dashed #6b5a1f; padding: 8px 14px;
}

/* Challenge-a-friend: create/join a private code */
.join-row { display: flex; gap: 8px; align-items: stretch; }
#joinCodeInput {
  font-family: "Press Start 2P", monospace; font-size: 15px; letter-spacing: 4px;
  text-transform: uppercase; text-align: center;
  width: 150px; padding: 10px; border: 3px solid #2d4a86;
  background: #0f1c36; color: #ffd866;
}
#joinCodeInput::placeholder { color: #4a628f; letter-spacing: 3px; }
#joinCodeInput:focus { outline: none; border-color: #ffd866; }

.menu-btn.ghost {
  background: #0f1c36; border-color: #45597f; color: #9fb3d6;
}

/* Online: name entry + your rating badge */
.name-row { display: flex; align-items: center; gap: 10px; justify-content: center; }
#playerNameInput {
  font-family: "Press Start 2P", monospace; font-size: 10px; letter-spacing: 1px;
  width: 190px; padding: 9px 10px; border: 2px solid #2d4a86;
  background: #0f1c36; color: #eaf0fb; text-align: center;
}
#playerNameInput::placeholder { color: #4a628f; }
#playerNameInput:focus { outline: none; border-color: #ffd866; }
.rating-badge {
  font-size: 9px; letter-spacing: 1px; color: #ffd866;
  border: 2px solid #6b5a1f; background: #1a1608; padding: 7px 12px;
}

/* PVP leaderboard */
.lb-list {
  list-style: none; margin: 0; padding: 0;
  width: 380px; max-width: 82vw; max-height: 46vh; overflow-y: auto;
  border: 2px solid #2d4a86; background: #0c1730;
}
.lb-row, .lb-empty {
  display: flex; align-items: center; gap: 10px;
  font-size: 9px; letter-spacing: 1px; color: #c9d6ea;
  padding: 9px 12px; border-bottom: 1px solid #16264a;
}
.lb-empty { justify-content: center; color: #6f86ad; }
.lb-row .lb-rank { width: 30px; color: #8fb4ee; text-align: right; }
.lb-row .lb-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-wl { color: #7f96bd; }
.lb-row .lb-elo { width: 54px; text-align: right; color: #ffd866; }
.lb-row.mine { background: #14223f; }
.lb-row.mine .lb-name { color: #6ee87a; }
.lb-list li:first-child .lb-rank { color: #ffd866; }

/* ---- RANKED: tier badges, leaderboard tabs, queue notes ---- */
.tier-badge {
  display: inline-block; font-size: 8px; letter-spacing: 1px;
  padding: 5px 8px; border: 2px solid; background: #0c1730;
  box-shadow: 2px 2px 0 #060a14; vertical-align: middle;
}
.tier-badge.provisional { opacity: .55; border-style: dashed; }
.lb-badge {
  width: 44px; text-align: center; font-size: 8px;
  border: 2px solid; padding: 3px 0; background: #0c1730;
}
.tier-bronze   { color: #d99a5b; border-color: #7a4a1e; }
.tier-silver   { color: #c8d4e4; border-color: #5c6b80; }
.tier-gold     { color: #ffd866; border-color: #8f5a18; }
.tier-platinum { color: #8ff0e0; border-color: #1e7a6a; }
.tier-diamond  { color: #9cc3ff; border-color: #2d4a86; }
.tier-champion { color: #ff5c8f; border-color: #8f1838; text-shadow: 0 0 8px rgba(255,92,143,.6); }

/* Leaderboard tabs */
.lb-tabs { display: flex; gap: 6px; }
.lb-tab {
  font-size: 9px; letter-spacing: 1px; padding: 8px 14px;
  border: 2px solid #2d4a86; background: #0f1c36; color: #9fb3d6; box-shadow: none;
}
.lb-tab:hover { background: #16264a; transform: none; box-shadow: none; }
.lb-tab:active { transform: translate(1px, 1px); box-shadow: none; }
.lb-tab.selected { border-color: #ffd866; background: #2a2410; color: #ffd866; }

/* Mode note under the RANKED/CASUAL chips (+ season label) */
.mode-note { font-size: 7px; letter-spacing: 1px; color: #6f86ad; }

/* Locked format chips while RANKED is selected */
.chip.locked { opacity: .35; pointer-events: none; }

/* End-screen promotion / demotion / streak */
#endRank { font-size: 11px; letter-spacing: 2px; }
#endRank.promo { color: #6ee87a; text-shadow: 2px 2px 0 #14401f; animation: bannerPop .25s steps(4) both; }
#endRank.demo  { color: #ff7a6e; text-shadow: 2px 2px 0 #4a1410; }
.streak { color: #ffb35c; font-size: 8px; letter-spacing: 1px; border: 2px solid #6b4a1f; padding: 3px 6px; margin-left: 8px; }

/* ---- STORE: coin economy + cosmetics/boosts shop ---- */
#menuStore { width: 96%; gap: 10px; }
.store-head { display: flex; align-items: center; gap: 16px; }
.coin-badge {
  font-size: 11px; letter-spacing: 1px; color: #ffd866;
  border: 2px solid #6b5a1f; background: #1a1608; padding: 7px 12px;
  display: inline-flex; align-items: center; gap: 7px;
}
.coin-ico {                       /* pixel coin: gold square with darker rim */
  width: 10px; height: 10px; background: #ffd866;
  box-shadow: inset -2px -2px 0 #8f5a18, inset 2px 2px 0 #ffedb0;
  display: inline-block;
}
.coin-badge.flash { animation: coinflash 0.5s steps(3); }
@keyframes coinflash { 50% { background: #3a3210; color: #fff; } }

.store-tabs { display: flex; gap: 6px; }
.store-tab {
  font-size: 9px; letter-spacing: 1px; padding: 9px 12px;
  border: 2px solid #2d4a86; background: #0f1c36; color: #9fb3d6; box-shadow: none;
}
.store-tab:hover { background: #16264a; transform: none; box-shadow: none; }
.store-tab:active { transform: translate(1px, 1px); box-shadow: none; }
.store-tab.selected { border-color: #ffd866; background: #2a2410; color: #ffd866; }
.store-tab.locked { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.store-tab.locked:hover { background: #0f1c36; }
.soon-tag { font-size: 6px; color: #ffd866; margin-left: 6px; vertical-align: super; }
.store-note { font-size: 7px; letter-spacing: 1px; color: #ffb35c; }

.store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px; width: 92%; max-height: 44vh; overflow-y: auto;
  padding: 10px; border: 2px solid #2d4a86; background: #0c1730;
}
.store-slot-label { grid-column: 1 / -1; font-size: 7px; letter-spacing: 2px;
  color: #8fb4ee; text-align: left; padding-top: 4px; }

.store-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 7px; background: #0f1c36; border: 2px solid #2d4a86;
  box-shadow: 3px 3px 0 #060a14;
}
.store-card.rarity-common    { border-color: #45597f; }
.store-card.rarity-rare      { border-color: #6ea8ff; }
.store-card.rarity-epic      { border-color: #a06bff; box-shadow: 3px 3px 0 #060a14, 0 0 10px rgba(160,107,255,.35); }
.store-card.rarity-legendary { border-color: #ffd866; box-shadow: 3px 3px 0 #060a14, 0 0 14px rgba(255,216,102,.45); }
.store-preview { image-rendering: pixelated; background: #0a0e1a; border: 1px solid #16264a; }
.store-name { font-size: 7px; letter-spacing: 1px; color: #eef2f7; line-height: 1.5; }
.store-rarity { font-size: 6px; letter-spacing: 1px; }
.rarity-common    .store-rarity { color: #9fb3d6; }
.rarity-rare      .store-rarity { color: #6ea8ff; }
.rarity-epic      .store-rarity { color: #a06bff; }
.rarity-legendary .store-rarity { color: #ffd866; }
.store-desc { font-size: 6px; letter-spacing: 0.5px; color: #8fa4c6; line-height: 1.6; }

.store-act {
  font-size: 8px; letter-spacing: 1px; padding: 7px 10px; width: 100%;
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  border: 2px solid #6ea8ff; background: #14223f; box-shadow: 2px 2px 0 #060a14;
}
.store-act .coin-ico { width: 8px; height: 8px; }
.store-act.buy.poor { border-color: #8f2018; color: #ff7a6e; opacity: 0.8; }
.store-act.equip { border-color: #6ee87a; color: #6ee87a; }
.store-act.equipped { border-color: #ffd866; background: #2a2410; color: #ffd866; }
.store-act.denied { animation: shake 0.3s steps(2) 2; }

/* Boost note under the big-hit meter (casual/offline matches only) */
#boostNote { color: #6ee87a; font-size: 7px; letter-spacing: 1px; }

/* Victory celebration: let the rink show through the end screen while playing */
#endScreen.celebrating { background: rgba(8, 12, 24, 0.45); }

/* Connection / matchmaking overlay */
#netOverlay { gap: 22px; }
.net-code {
  font-size: 40px; letter-spacing: 10px; color: #ffd866;
  padding: 14px 20px; border: 4px solid #ffd866; background: #14223f;
  box-shadow: 6px 6px 0 #060a14;
}
.net-spinner {
  width: 46px; height: 46px;
  border: 5px solid #1d3158; border-top-color: #6ea8ff; border-radius: 50%;
  animation: netspin 0.8s linear infinite;
}
@keyframes netspin { to { transform: rotate(360deg); } }

/* 2v2 "call for a pass" button — floats top-center over the rink during play */
#passBtn {
  position: absolute;
  right: 1.5%; bottom: 46%;       /* pushed to the right edge, above the stick */
  z-index: 3;
  font-size: 9px; letter-spacing: 1px;
  padding: 8px 12px;
  border: 2px solid rgba(110, 168, 255, 0.45);
  background: rgba(20, 34, 63, 0.32);   /* translucent, like the thumb-sticks */
  color: rgba(207, 224, 255, 0.85);
  box-shadow: none;
}
#passBtn:hover { background: rgba(29, 49, 88, 0.4); transform: none; box-shadow: none; }
#passBtn:active { transform: translate(1px, 1px); box-shadow: none; }
#passBtn.ready { border-color: rgba(255, 216, 102, 0.85); color: #ffd866; background: rgba(42, 36, 16, 0.5); animation: passpulse 0.7s ease-in-out infinite; }
@keyframes passpulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 216, 102, 0); }
  50% { box-shadow: 0 0 12px rgba(255, 216, 102, 0.55); }
}

/* Full-screen control overlay — the thumb-sticks draw here, in the margins
   around the rink. pointer-events enabled only on touch devices (via JS). */
#touchCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  touch-action: none;
}

button {
  font-family: "Press Start 2P", monospace;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 14px 28px;
  border: 3px solid #6ea8ff;
  background: #14223f;
  color: #eef2f7;
  cursor: pointer;
  box-shadow: 4px 4px 0 #060a14;
  transition: transform 0.1s, background 0.15s;
}
button:hover { background: #1d3158; transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #060a14; }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #060a14; }

.hidden { display: none !important; }

#banner {
  position: absolute;
  top: 38%;
  left: 0; right: 0;
  text-align: center;
  font-size: 30px;
  letter-spacing: 3px;
  color: #ffd866;
  text-shadow: 3px 3px 0 #8f2018, 0 0 24px rgba(255, 120, 40, 0.9);
  pointer-events: none;
  z-index: 3;
  animation: bannerPop 0.25s steps(4) both;
}
@keyframes bannerPop {
  from { transform: scale(2.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.fight-title {
  color: #ff5c4d !important;
  text-shadow: 3px 3px 0 #500 !important;
  animation: shake 0.3s steps(2) infinite;
  font-size: 40px !important;
}
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-2deg); }
  75% { transform: translate(3px, -2px) rotate(2deg); }
}

#fightDesc { font-size: 10px; line-height: 1.9; max-width: 80%; color: #c9d6ea; }

#qteDots { display: flex; gap: 10px; }
.qte-dot {
  width: 16px; height: 16px;
  border: 2px solid #eef2f7;
  background: #060a14;
}
.qte-dot.win { background: #6ee87a; border-color: #6ee87a; }
.qte-dot.lose { background: #ff5c4d; border-color: #ff5c4d; }

#qteKey {
  min-width: 120px;
  padding: 22px 26px;
  border: 4px solid #ffd866;
  background: #14223f;
  color: #ffd866;
  font-size: 44px;
  text-shadow: 3px 3px 0 #8f5a18;
  box-shadow: 6px 6px 0 #060a14;
}
#qteKey.qte-hit { color: #6ee87a; border-color: #6ee87a; font-size: 26px; }
#qteKey.qte-miss { color: #ff5c4d; border-color: #ff5c4d; font-size: 26px; }

#qteTimerWrap {
  width: 50%;
  height: 14px;
  border: 3px solid #eef2f7;
  background: #060a14;
  overflow: hidden;
}
#qteTimer { background: #ffd866; height: 100%; width: 100%; }

.fight-hint { font-size: 13px; color: #ffd866; animation: shake 0.5s steps(2) infinite; }

/* Touch QTE: tap the button showing the prompted key */
#qteButtons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.qte-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 26px;
  width: 66px; height: 66px;
  padding: 0;
  border: 3px solid #6ea8ff;
  background: #14223f;
  color: #eef2f7;
  box-shadow: 3px 3px 0 #060a14;
}
.qte-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #060a14; }

footer {
  flex: 0 0 auto;
  text-align: center;
  margin-top: 10px;
  font-size: 8px;
  color: #6b7a96;
  letter-spacing: 1px;
  line-height: 1.8;
}

/* ---- Mobile / short-landscape ----
   Triggers on narrow width OR short height — a phone in landscape is WIDE
   (~932px) but SHORT (~430px), so the height test is what actually catches it.
   Drops the big title, shrinks the HUD, and hides the footer to give the rink
   as much room as possible. */
#rotateHint { display: none; }

@media (max-width: 820px), (max-height: 560px) {
  #wrap {
    padding:
      max(4px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }
  header h1 { display: none; }
  #hud { font-size: 15px; gap: 12px; margin-bottom: 3px; }
  #clock { font-size: 13px; padding: 3px 9px; border-width: 2px; }
  #hitMeter { font-size: 6px; gap: 6px; margin-bottom: 3px; }
  .pip { width: 13px; height: 7px; }
  footer { display: none; }
  canvas { border-width: 2px; }

  .overlay { gap: 9px; padding: 12px; }
  .overlay h2 { font-size: 17px; }
  .settings { gap: 6px; }
  .rules { font-size: 7px; line-height: 1.85; }
  .overlay .tagline { font-size: 8px; }
  .tagline.big { font-size: 12px; }
  .menu-btn { min-width: 220px; }
  button { font-size: 11px; padding: 10px 18px; }
  #startBtn { font-size: 12px; }
  .tier-badge { font-size: 7px; padding: 4px 6px; }
  .lb-tab { font-size: 8px; padding: 6px 10px; }
  .store-grid { max-height: 52vh; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .store-tab { font-size: 8px; padding: 7px 9px; }
}

/* On a phone in portrait, ask the player to turn it sideways */
@media (max-width: 920px) and (orientation: portrait) and (pointer: coarse) {
  #wrap { display: none; }
  #rotateHint {
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #0d1321;
    z-index: 50;
  }
  #rotateHint .rotate-icon { font-size: 64px; color: #6ea8ff; animation: rothint 1.6s ease-in-out infinite; }
  #rotateHint p { font-size: 14px; color: #9cc3ff; margin: 18px 0 8px; letter-spacing: 2px; }
  #rotateHint small { font-size: 9px; color: #6b7a96; }
}
@keyframes rothint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
