/* ── Progress bar header ─────────────────────────── */

.prog-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 0 4px;
}
.prog-info {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: rgba(255,255,255,0.48);
  white-space: nowrap;
}
.prog-info--lebron {
  color: rgba(245,158,11,0.82);
}

/* ── Progress bar ─────────────────────────────── */

#prog-wrap {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 8px;
  box-sizing: border-box;
}
#prog-track {
  position: relative;
  height: 36px;
}
#prog-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}
.prog-segment {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 1;
}
.prog-player {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Outfit", sans-serif;
  font-size: 7px;
  font-weight: 900;
  color: #111827;
  z-index: 2;
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 1px 5px rgba(0,0,0,0.28);
  transition: filter 0.4s, opacity 0.4s, border-color 0.4s;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
.prog-player--img {
  background: transparent;
  overflow: hidden;
}
.prog-player--passed {
  filter: grayscale(1);
  opacity: 0.28;
  border-color: rgba(255,255,255,0.15);
}
.prog-player--lebron {
  background: #f59e0b;
  border-color: #fbbf24;
  color: #111;
  font-size: 8px;
  width: 30px;
  height: 30px;
  box-shadow: 0 0 10px rgba(245,158,11,0.45), 0 1px 5px rgba(0,0,0,0.28);
}

/* ── Canvas ──────────────────────────────────────── */

.game-stage {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(0,0,0,0.35);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

#game {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 9;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#introduction {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(860px, 92%);
  text-align: center;
  color: rgba(255,255,255,0.92);
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
  z-index: 6;
  transition: opacity 0.35s;
  pointer-events: none;
}
#perfect {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.40);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Power bar ───────────────────────────────────── */

#powerbar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  height: 10px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
  z-index: 6;
  pointer-events: none;
}
#powerbar > div {
  height: 100%;
  width: 0%;
  background: rgba(255,255,255,0.85);
  transition: width 0.06s linear;
}

/* ── Overlays ────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.overlay--gameover {
  background: rgba(0,0,0,0.30);
  position: fixed;
  border-radius: 0;
  z-index: 200;
  align-items: flex-start;
  overflow-y: auto;
  padding: 20px 0;
  -webkit-overflow-scrolling: touch;
}
.overlay--gameover .overlay-card {
  margin: auto;
  max-height: none;
}
.overlay-card {
  position: relative;
  width: min(540px, 92%);
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 18px;
  padding: 13px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}
.overlay-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(17,24,39,0.35);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  z-index: 1;
}
.overlay-close:hover { color: rgba(17,24,39,0.80); }
.overlay-title {
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.02em;
}
.overlay-sub { margin-top: 6px; font-weight: 700; opacity: 0.85; font-size: 14px; }

.stats-wrap {
  margin-top: 12px;
  text-align: left;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 12px;
}
.stats-title { font-weight: 900; margin-bottom: 8px; }
.stats-box { font-weight: 800; opacity: 0.92; line-height: 1.5; font-size: 14px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0; }
.stat-label { color: rgba(17,24,39,0.60); font-weight: 700; }
.stat-val { font-weight: 900; }
.trophy-count { font-size: 14px; font-weight: 700; padding: 4px 0; grid-column: 1 / -1; white-space: nowrap; }
.trophy-count-link { color: #f97316; font-weight: 800; text-decoration: none; }
.trophy-count-link:hover { text-decoration: underline; }
.share-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.share-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 10px 6px; background: var(--share-color); border-radius: 10px;
  text-decoration: none; color: #fff; font-family: "Outfit", sans-serif;
  transition: opacity 0.15s, transform 0.1s; cursor: pointer; border: none;
}
.share-btn:hover { opacity: 0.85; transform: scale(1.03); }
.share-btn-label { font-size: 11px; font-weight: 700; text-align: center; line-height: 1.2; }

.share-wrap {
  margin-top: 10px;
  text-align: left;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 12px;
}
.share-title { font-weight: 900; margin-bottom: 8px; }
.share-text {
  font-weight: 800;
  opacity: 0.92;
  line-height: 1.5;
  word-break: break-word;
  font-size: 13px;
}

/* ── Trophy toast (top-left of game-stage) ────────── */

#trophy-notif {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.22);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  z-index: 25;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28);
  transition: opacity 0.35s;
  display: none;
}
#trophy-notif[data-tier="bronze"] {
  background: rgba(205,127,50,0.95);
  color: #111827;
  border-color: rgba(205,127,50,0.55);
}
#trophy-notif[data-tier="silver"] {
  background: rgba(192,192,192,0.95);
  color: #111827;
  border-color: rgba(192,192,192,0.55);
}
#trophy-notif[data-tier="gold"] {
  background: rgba(234,179,8,0.97);
  color: #111827;
  border-color: rgba(245,158,11,0.60);
}
#trophy-notif[data-tier="diamond"] {
  background: rgba(34,211,238,0.95);
  color: #111827;
  border-color: rgba(103,232,249,0.60);
}
#trophy-notif[data-tier="multi"] {
  background: linear-gradient(135deg, #ef4444, #f97316, #eab308, #22c55e, #6366f1);
  color: #fff;
  border-color: transparent;
  animation: trophy-rainbow 3s linear infinite;
}

/* ── Trophies (game over overlay) ────────────────── */

.trophies-wrap {
  margin-top: 10px;
  text-align: left;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 12px;
}
.trophies-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}
.trophy-item {
  border-radius: 10px;
  padding: 8px 10px;
}
.trophy-item--unlocked {
  background: rgba(0,0,0,0.06);
}
.trophy-item--locked {
  background: rgba(0,0,0,0.03);
  opacity: 0.40;
}
.trophy-item--new {
  background: rgba(234,179,8,0.16);
  border: 1px solid rgba(234,179,8,0.45);
  opacity: 1;
}
.trophy-name {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #111827;
}
.trophy-desc {
  font-weight: 600;
  font-size: 10px;
  opacity: 0.70;
  margin-top: 2px;
  color: #111827;
}

/* ── Lives bar ────────────────────────────────────── */

#lives-bar {
  position: absolute;
  bottom: 40px;
  left: 14px;
  display: flex;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}
.life-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: opacity 0.55s, filter 0.55s;
}
.life-portrait {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.55);
  box-shadow: 0 2px 8px rgba(0,0,0,0.30);
}
.life-portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.life-item--lost {
  opacity: 0.18;
  filter: grayscale(1);
}

/* ── GOAT popup ──────────────────────────────────── */

.overlay--goat {
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.goat-card {
  background: linear-gradient(160deg, #fef9ee 0%, #fde68a 55%, #fbbf24 100%);
  border: 2px solid #f59e0b;
  box-shadow: 0 24px 60px rgba(245,158,11,0.28), 0 8px 24px rgba(0,0,0,0.18);
}
.goat-crown {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 4px;
  color: #b45309;
  text-shadow: 0 2px 8px rgba(180,83,9,0.25);
}
.goat-title {
  color: #78350f;
  font-size: 36px;
  letter-spacing: 0.06em;
  text-shadow: none;
}
.start-btn--goat {
  background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
  color: #fef9ee;
  border: none;
  box-shadow: 0 4px 14px rgba(180,83,9,0.30);
}
.start-btn--goat:hover { opacity: 0.88; }

/* ── Restart button (inside game-stage) ─────────── */

.stage-restart-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.52);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.30);
  transition: opacity 0.15s;
}
.stage-restart-btn:hover { opacity: 0.78; }

/* ── Fullscreen button (inside game-stage) ───────── */

.stage-fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.52);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.30);
  transition: opacity 0.15s;
}
.stage-fullscreen-btn:hover { opacity: 0.78; }

/* ── Score badge (inside game-stage, fullscreen only) */

.stage-score-badge {
  position: absolute;
  top: 10px;
  right: 56px;
  z-index: 15;
  pointer-events: none;
  display: block;
  background: rgba(0,0,0,0.60);
  color: #fff;
  font-family: "Outfit", sans-serif;
  font-weight: 900;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.28);
  white-space: nowrap;
}

@keyframes trophy-rainbow {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ── Fullscreen state ────────────────────────────── */

.game-stage:fullscreen,
.game-stage:-webkit-full-screen {
  max-width: none;
  border-radius: 0;
  background: #000;
}

.game-stage:fullscreen .stage-fullscreen-btn,
.game-stage:-webkit-full-screen .stage-fullscreen-btn {
  display: flex;
}

.game-stage:fullscreen .stage-score-badge,
.game-stage:-webkit-full-screen .stage-score-badge {
  right: 56px;
}

/* ── Rotate hint (mobile portrait) ──────────────── */

.rotate-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: inherit;
}
.rotate-hint svg {
  animation: rotate-bounce 1.6s ease-in-out infinite;
}
.rotate-hint-label {
  color: rgba(255,255,255,0.88);
  font-family: "Outfit", sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rotate-hint-sub {
  color: rgba(255,255,255,0.50);
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  font-weight: 600;
  margin-top: -6px;
  text-align: center;
}
.rotate-hint-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.rotate-hint-close:hover { color: #fff; }
.rotate-hint.dismissed { display: none !important; }
@keyframes rotate-bounce {
  0%   { transform: rotate(0deg);   }
  40%  { transform: rotate(-20deg); }
  60%  { transform: rotate(-20deg); }
  100% { transform: rotate(0deg);   }
}

@media (max-width: 640px) and (orientation: portrait) {
  .rotate-hint { display: flex; }
}

/* ── Character select modal ─────────────────────── */

.character-modal-card {
  width: min(640px, 92vw);
  max-width: 640px;
}
.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
}
.character-card {
  background: rgba(17,24,39,0.05);
  border: 2px solid rgba(17,24,39,0.12);
  border-radius: 16px;
  padding: 18px 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: "Outfit", sans-serif;
}
.character-card:hover {
  border-color: #f97316;
  background: rgba(249,115,22,0.07);
  transform: translateY(-3px);
}
.character-card-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
}
.character-card-name {
  font-weight: 800;
  font-size: 13px;
  color: #111827;
  line-height: 1.2;
  text-align: center;
}
.character-card-nick {
  font-weight: 700;
  font-size: 11px;
  color: #f97316;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@media (max-width: 500px) {
  .character-modal-card {
    width: 92vw;
    padding: 24px 16px 20px;
  }
  .character-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding: 4px 4px 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(249,115,22,0.5) rgba(17,24,39,0.08);
  }
  .character-grid::-webkit-scrollbar {
    height: 5px;
    border-radius: 3px;
  }
  .character-grid::-webkit-scrollbar-track {
    background: rgba(17,24,39,0.08);
    border-radius: 3px;
  }
  .character-grid::-webkit-scrollbar-thumb {
    background: rgba(249,115,22,0.55);
    border-radius: 3px;
  }
  .character-card {
    flex: 0 0 62%;
    scroll-snap-align: center;
  }
  .character-card-img {
    width: 90px;
    height: 90px;
  }
}

/* ── Change character button (game-over overlay) ─── */

.change-character-btn {
  margin-top: 6px;
  width: 100%;
  height: 38px;
  border-radius: 999px;
  border: 1.5px solid rgba(17,24,39,0.15);
  background: transparent;
  color: rgba(17,24,39,0.55);
  font-weight: 700;
  font-family: "Outfit", sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.change-character-btn:hover {
  border-color: #f97316;
  color: #f97316;
  background: rgba(249,115,22,0.05);
}

/* ── HOF link in game-over overlay ──────────────── */

.hof-link-btn {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: rgba(17,24,39,0.50);
  text-decoration: none;
  transition: color 0.15s;
}
.hof-link-btn:hover { color: #111827; }

/* ── Touch vs mouse instruction ─────────────────── */

.intro-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .intro-mouse { display: none; }
  .intro-touch { display: inline; }
}

/* ── Mobile fullscreen hint (inside game-stage) ─── */

.mobile-fullscreen-hint {
  display: none;
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  color: rgba(255,255,255,0.88);
  font-family: "Outfit", sans-serif;
  font-weight: 800;
  font-size: 11px;
  padding: 6px 16px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 7;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.15);
}
@media (hover: none) and (pointer: coarse) {
  .mobile-fullscreen-hint { display: block; }
}
.game-stage:fullscreen .mobile-fullscreen-hint,
.game-stage:-webkit-full-screen .mobile-fullscreen-hint {
  display: none !important;
}

/* ── Mobile landscape optimization ─────────────── */

@media (max-width: 900px) and (orientation: landscape) {
  .page { margin-top: 4px; margin-bottom: 4px; }
  .hero { display: none; }
  #prog-wrap { display: none; }
  .game-wrap { margin-top: 0; }

  .game-stage {
    width: auto;
    max-width: 100%;
    height: calc(100vh - 54px);
    height: calc(100dvh - 54px);
    aspect-ratio: 16 / 9;
    margin: 0 auto;
  }

  #game {
    width: 100%;
    height: 100%;
    aspect-ratio: unset;
  }

  #introduction { font-size: 11px; top: 32px; }
  #perfect { font-size: 14px; top: 52px; }
  #powerbar { bottom: 6px; left: 8px; right: 8px; height: 5px; }
  #lives-bar { bottom: 18px; left: 8px; gap: 4px; }
  .life-portrait { width: 26px; height: 26px; }
  .mobile-fullscreen-hint { bottom: 30px; }
}

/* ── Tablet ──────────────────────────────────────── */

@media (max-width: 900px) {
  .overlay-card { padding: 12px; }
  #prog-track { height: 22px; }
  .prog-player { width: 18px; height: 18px; font-size: 5px; }
  .prog-player--lebron { width: 22px; height: 22px; }
  .prog-info { font-size: 10px; }
}

/* ── Mobile ──────────────────────────────────────── */

@media (max-width: 640px) {
  /* Progress labels */
  .prog-header { padding-bottom: 3px; }
  .prog-info { font-size: 9px; }

  /* Canvas */
  .game-stage { border-radius: 8px; }
  #introduction { font-size: 12px; top: 40px; width: 88%; }
  #perfect { font-size: 15px; top: 62px; }
  #powerbar { bottom: 8px; left: 8px; right: 8px; height: 6px; }

  /* Progress bar */
  #prog-wrap { margin-bottom: 4px; }
  #prog-track { height: 14px; }
  #prog-rail { height: 3px; }
  .prog-segment { height: 3px; }
  .prog-player { width: 10px; height: 10px; font-size: 0px; border-width: 1px; }
  .prog-player--img { background: rgba(255,255,255,0.85); }
  .prog-player--lebron { width: 13px; height: 13px; font-size: 0px; }
  .prog-player img { display: none; }

  /* Lives */
  #lives-bar { bottom: 22px; left: 8px; gap: 5px; }
  .life-portrait { width: 28px; height: 28px; }

  /* Trophy toast */
  #trophy-notif { font-size: 10px; padding: 5px 12px; }

  /* Trophies grid */
  .trophies-list { grid-template-columns: 1fr; }

  /* Overlay */
  .overlay-card { padding: 11px 10px; }
  .overlay-title { font-size: 20px; }
  .overlay-sub { font-size: 12px; }
}
