* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #172033;
  display: grid;
  place-items: center;
  padding: 16px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.52rem 0.72rem;
  font-weight: 850;
  cursor: pointer;
  background: #175cd3;
  color: white;
  transition: transform 0.08s ease, filter 0.08s ease;
  font-size: 0.86rem;
}

button:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary {
  background: #475467;
}

button.danger {
  background: #b42318;
}

button.success {
  background: #16803c;
}

button.option-button {
  width: 100%;
  text-align: left;
  margin-top: 0.46rem;
  background: #175cd3;
  padding-top: 0.74rem;
  padding-bottom: 0.74rem;
}

button.play-button {
  width: 100%;
  margin-top: 0.6rem;
}

.page-shell {
  width: min(960px, calc(100vw - 32px), calc((100vh - 150px) * 16 / 9));
  display: grid;
  gap: 12px;
}

/* Phone landscape game window */
.app-shell {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 150px);
  overflow: hidden;
  background: #eef2f7;
  border: 10px solid #020617;
  border-radius: 32px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  padding: 14px;

  display: grid;
  grid-template-rows: 19% minmax(0, 1fr) auto;
  gap: 0.55rem;
}

/* Top band: all player state and round state lives here */
.top-band {
  min-height: 0;
  background: white;
  border-radius: 22px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  padding: 0.45rem;
  display: grid;
  grid-template-columns: 1.12fr 4fr;
  gap: 0.55rem;
  align-items: stretch;
  overflow: hidden;
}

.brand-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3.1vw, 2.25rem);
  line-height: 0.9;
  letter-spacing: -0.055em;
}

#packSubtitle {
  margin: 0.28rem 0 0;
  color: #667085;
  font-weight: 750;
  font-size: 0.7rem;
  line-height: 1.05;
}

.hud-strip {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 0.65fr 0.65fr 0.65fr 1fr 1fr 0.9fr;
  grid-template-rows: minmax(0, 1fr) 24px;
  gap: 0.32rem;
}

.hud-item {
  min-width: 0;
  min-height: 0;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #eaecf0;
  padding: 0.24rem 0.38rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-label {
  display: block;
  color: #667085;
  font-size: 0.48rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.hud-value {
  display: block;
  margin-top: 0.03rem;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.hud-value.text-value {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: -0.025em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-message {
  grid-column: 1 / -1;
  height: 24px;
  min-height: 0;
  border-radius: 12px;
  background: #eef4ff;
  border: 1px solid #d1e0ff;
  color: #172033;
  padding: 0.12rem 0.46rem;
  font-weight: 900;
  line-height: 1;
  font-size: 0.62rem;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.play-area {
  background: white;
  border-radius: 18px;
  padding: 0.68rem 0.85rem;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  min-height: 0;
  overflow: hidden;

  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

#gameArea {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.cards-grid {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.65rem;
  align-items: stretch;
}

.card {
  border: 3px solid #d0d5dd;
  border-radius: 18px;
  padding: 0.78rem;
  background: #fcfcfd;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  overflow: hidden;
}

.card > div {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card.unlocked {
  border-color: #12b76a;
  background: #f6fef9;
}

.card.failed {
  border-color: #f04438;
  background: #fff6f5;
}

.card.battle-card {
  min-height: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  align-items: flex-start;
  margin-bottom: 0.45rem;
}

.card-status {
  display: inline-flex;
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 950;
  background: #eaecf0;
  color: #344054;
  white-space: nowrap;
}

.card-status.unlocked {
  background: #dcfae6;
  color: #067647;
}

.card-status.failed {
  background: #fee4e2;
  color: #b42318;
}

.card-word {
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: -0.03em;
}

.card-translation {
  color: #475467;
  font-weight: 750;
  margin-top: 0.1rem;
  font-size: 0.82rem;
}

.card-sentence {
  margin: 0.4rem 0;
  font-style: italic;
  color: #344054;
  font-size: 0.82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.22rem;
  margin-top: 0.38rem;
  font-size: 0.82rem;
}

.stat-name {
  color: #475467;
  font-weight: 750;
}

.stat-value {
  font-weight: 950;
}

.highlight-stat {
  color: #175cd3;
}

.question-prompt {
  font-weight: 900;
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
  line-height: 1.22;
}

.feedback {
  margin-top: 0.5rem;
  font-weight: 850;
  font-size: 0.82rem;
}

.battle-grid {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.65rem;
}

.battle-summary {
  margin-top: 0.65rem;
  padding: 0.65rem;
  background: #f9fafb;
  border: 1px solid #eaecf0;
  border-radius: 14px;
  font-weight: 850;
  font-size: 0.9rem;
}

.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 0;
}

/* Developer/log area sits outside the phone play window */
.dev-tools {
  color: #172033;
  display: grid;
  gap: 0.65rem;
}

.log-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.debug-panel {
  background: white;
  border-radius: 18px;
  padding: 0.68rem 0.85rem;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.12);
  font-size: 0.82rem;
  max-height: 120px;
  overflow: auto;
}

.hidden {
  display: none !important;
}

pre {
  white-space: pre-wrap;
  max-height: 80px;
  overflow: auto;
}

@media (max-width: 820px), (max-height: 560px) {
  body {
    padding: 8px;
  }

  .page-shell {
    width: calc(100vw - 16px);
  }

  .app-shell {
    max-height: calc(100vh - 128px);
    border-width: 6px;
    border-radius: 24px;
    padding: 10px;
    gap: 0.45rem;
  }

  .top-band {
    grid-template-columns: 0.95fr 4fr;
    padding: 0.36rem;
    gap: 0.4rem;
  }

  h1 {
    font-size: 1.2rem;
  }

  #packSubtitle {
    font-size: 0.56rem;
  }

  .hud-strip {
    grid-template-columns: 0.58fr 0.58fr 0.58fr 0.95fr 0.95fr 0.85fr;
    grid-template-rows: minmax(0, 1fr) 20px;
    gap: 0.22rem;
  }

  .hud-item {
    padding: 0.18rem 0.26rem;
    border-radius: 11px;
  }

  .hud-label {
    font-size: 0.4rem;
  }

  .hud-value {
    font-size: 0.85rem;
  }

  .hud-value.text-value {
    font-size: 0.54rem;
  }

  .hud-message {
    height: 20px;
    font-size: 0.52rem;
    padding: 0.08rem 0.32rem;
  }

  .card {
    min-height: 0;
  }

  button {
    font-size: 0.76rem;
    padding: 0.42rem 0.55rem;
  }
}

/* Battle transition animations */
.unlock-grid {
  perspective: 900px;
}

.unlock-card {
  transform-origin: center center;
  will-change: transform, opacity;
}

.unchosen-card-drop {
  animation: unchosenCardDrop 650ms cubic-bezier(.22,.8,.26,.99) forwards;
  pointer-events: none;
}

.chosen-card-exit {
  z-index: 4;
  animation: chosenCardExitLeft 680ms cubic-bezier(.16,1,.3,1) forwards;
  pointer-events: none;
}

@keyframes unchosenCardDrop {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
  45% {
    opacity: 0.9;
    transform: translateY(10px) rotate(-3deg) scale(0.98);
  }
  100% {
    opacity: 0;
    transform: translateY(160px) rotate(9deg) scale(0.88);
  }
}

@keyframes chosenCardExitLeft {
  0% {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
  }
  35% {
    transform: translateX(-18px) rotate(-2deg) scale(1.03);
  }
  100% {
    opacity: 0;
    transform: translateX(-115%) rotate(-8deg) scale(0.96);
  }
}

.battle-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.7rem;
  overflow: hidden;
  perspective: 1000px;
}

.battle-card-slot {
  min-height: 0;
  display: flex;
}

.battle-card-slot .battle-card {
  width: 100%;
}

.player-slot {
  grid-column: 1;
  grid-row: 1;
}

.ai-slot {
  grid-column: 3;
  grid-row: 1;
}

.battle-vs {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #111827;
  color: white;
  font-weight: 950;
  letter-spacing: -0.05em;
  transform: scale(0.6);
  opacity: 0;
  animation: vsPop 520ms ease-out 720ms forwards;
}

.animated-battle-card {
  opacity: 0;
  will-change: transform, opacity;
}

.player-battle-card {
  transform: translateX(-90%) rotate(-8deg) scale(0.94);
  animation: playerCardEnter 760ms cubic-bezier(.16,1,.3,1) forwards;
}

.ai-battle-card {
  transform: translateX(95%) rotate(8deg) scale(0.94);
  animation: aiCardEnter 760ms cubic-bezier(.16,1,.3,1) 360ms forwards;
}

@keyframes playerCardEnter {
  0% {
    opacity: 0;
    transform: translateX(-90%) rotate(-8deg) scale(0.94);
  }
  72% {
    opacity: 1;
    transform: translateX(3%) rotate(1deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotate(-1deg) scale(1);
  }
}

@keyframes aiCardEnter {
  0% {
    opacity: 0;
    transform: translateX(95%) rotate(8deg) scale(0.94);
  }
  72% {
    opacity: 1;
    transform: translateX(-3%) rotate(-1deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotate(1deg) scale(1);
  }
}

@keyframes vsPop {
  0% {
    opacity: 0;
    transform: scale(0.6) rotate(-8deg);
  }
  70% {
    opacity: 1;
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.battle-impact {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 999px;
  background: rgba(23, 92, 211, 0.18);
  border: 4px solid rgba(23, 92, 211, 0.38);
  opacity: 0;
  animation: battleImpact 440ms ease-out 980ms forwards;
  pointer-events: none;
}

@keyframes battleImpact {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(2.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.5);
  }
}

.battle-number-pill {
  margin: 0.45rem 0;
  border-radius: 14px;
  background: #eef4ff;
  border: 1px solid #d1e0ff;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.battle-number-label {
  color: #475467;
  font-weight: 850;
  font-size: 0.72rem;
}

.hidden-battle-number {
  display: inline-block;
  filter: blur(8px);
  opacity: 0.12;
  transform: scale(0.8);
  transition:
    filter 260ms ease-out,
    opacity 260ms ease-out,
    transform 260ms cubic-bezier(.16,1,.3,1);
}

.battle-number-pill strong.hidden-battle-number {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 950;
}

.numbers-revealed .hidden-battle-number {
  filter: blur(0);
  opacity: 1;
  transform: scale(1);
}

.animated-summary {
  grid-column: 1 / -1;
  grid-row: 2;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 260ms ease-out,
    transform 260ms ease-out;
}

.numbers-revealed .animated-summary {
  opacity: 1;
  transform: translateY(0);
}

.numbers-revealed.player-wins .player-battle-card {
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.22);
}

.numbers-revealed.ai-wins .ai-battle-card {
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.2);
}

.numbers-revealed.draw-battle .player-battle-card,
.numbers-revealed.draw-battle .ai-battle-card {
  box-shadow: 0 0 0 4px rgba(102, 112, 133, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  .unchosen-card-drop,
  .chosen-card-exit,
  .player-battle-card,
  .ai-battle-card,
  .battle-vs,
  .battle-impact {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
  }

  .hidden-battle-number,
  .animated-summary {
    transition-duration: 1ms !important;
  }
}

/* PATCH: standard playing-card sizing */
:root {
  --card-w: 150px;
  --card-h: 213px;
}

.play-area {
  overflow: hidden;
}

#gameArea {
  display: grid;
  place-items: center;
}

.cards-grid {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, var(--card-w));
  grid-auto-rows: var(--card-h);
  justify-content: space-evenly;
  align-content: center;
  align-items: center;
  gap: clamp(8px, 2vw, 18px);
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  min-width: var(--card-w);
  min-height: var(--card-h);
  max-width: var(--card-w);
  max-height: var(--card-h);
  aspect-ratio: 5 / 7.1;
  overflow: hidden;
}

.card > div {
  min-height: 0;
  overflow: hidden;
}

.card-word {
  font-size: clamp(0.84rem, calc(var(--card-w) * 0.068), 1.06rem);
}

.card-translation,
.card-sentence,
.stats-grid,
.question-prompt,
.feedback {
  font-size: clamp(0.68rem, calc(var(--card-w) * 0.054), 0.84rem);
}

.card-status {
  font-size: clamp(0.5rem, calc(var(--card-w) * 0.04), 0.62rem);
}

button.option-button {
  font-size: clamp(0.66rem, calc(var(--card-w) * 0.055), 0.84rem);
  padding-top: clamp(0.36rem, calc(var(--card-h) * 0.028), 0.68rem);
  padding-bottom: clamp(0.36rem, calc(var(--card-h) * 0.028), 0.68rem);
}

button.play-button {
  font-size: clamp(0.68rem, calc(var(--card-w) * 0.055), 0.84rem);
}

/* Battle cards use the same standard card size */
.battle-stage {
  width: 100%;
  height: 100%;
  grid-template-columns: var(--card-w) 72px var(--card-w);
  justify-content: center;
  align-content: center;
}

.battle-card-slot {
  width: var(--card-w);
  height: var(--card-h);
}

.battle-card-slot .battle-card,
.animated-battle-card {
  width: var(--card-w);
  height: var(--card-h);
  min-width: var(--card-w);
  min-height: var(--card-h);
  max-width: var(--card-w);
  max-height: var(--card-h);
}

.battle-summary {
  max-width: calc((var(--card-w) * 2) + 72px + 1.4rem);
  justify-self: center;
  width: 100%;
}

@media (max-width: 820px), (max-height: 560px) {
  .cards-grid {
    grid-template-columns: repeat(3, var(--card-w));
    grid-auto-rows: var(--card-h);
  }

  .card {
    width: var(--card-w);
    height: var(--card-h);
    min-width: var(--card-w);
    min-height: var(--card-h);
  }
}

/* PATCH: locked card header replaced by padlock icon */
.locked-card-content {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lock-icon {
  position: absolute;
  top: 0;
  right: 0;
  width: clamp(28px, calc(var(--card-w) * 0.22), 42px);
  height: clamp(28px, calc(var(--card-w) * 0.22), 42px);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eaecf0;
  border: 1px solid #d0d5dd;
  font-size: clamp(1rem, calc(var(--card-w) * 0.11), 1.35rem);
  line-height: 1;
}

.locked-question {
  padding-top: clamp(2.2rem, calc(var(--card-h) * 0.15), 3.1rem);
  padding-right: 0;
  margin-bottom: 0.7rem;
}

/* PATCH: Y-axis unlock flip */
.unlock-grid {
  perspective: 1200px;
}

.unlock-card {
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.card-flip-x {
  animation: cardFlipY 700ms cubic-bezier(.2,.8,.2,1) forwards;
  pointer-events: none;
  transform-origin: center center;
  will-change: transform;
}

.card-flip-revealed {
  transform: rotateY(180deg);
}

@keyframes cardFlipY {
  0% {
    transform: rotateY(0deg) scale(1);
    box-shadow: none;
  }
  45% {
    transform: rotateY(89deg) scale(1.03);
    box-shadow: 0 18px 34px rgba(16, 24, 40, 0.18);
  }
  55% {
    transform: rotateY(91deg) scale(1.03);
    box-shadow: 0 18px 34px rgba(16, 24, 40, 0.18);
  }
  100% {
    transform: rotateY(180deg) scale(1);
    box-shadow: none;
  }
}

/*
  The DOM content is swapped halfway through the flip.
  This inner counter-rotation makes the revealed face readable
  while the card itself finishes the Y-axis spin.
*/
.card-flip-revealed > div {
  transform: rotateY(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .card-flip-x {
    animation-duration: 1ms !important;
  }
}

/* PATCH: centre Next Round / Restart as play-area overlay */
.play-area {
  position: relative;
}

.overlay-controls {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: transparent;
}

.overlay-controls button {
  pointer-events: auto;
  min-width: 170px;
  padding: 0.9rem 1.25rem;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow:
    0 18px 40px rgba(16, 24, 40, 0.28),
    0 0 0 4px rgba(255, 255, 255, 0.9);
}

.overlay-controls button.hidden {
  display: none !important;
}

/* No separate controls row is needed inside the phone frame now. */
.app-shell {
  grid-template-rows: 19% minmax(0, 1fr);
}

.game-controls:not(.overlay-controls) {
  display: none;
}

/* PATCH: 30-second selection timer HUD */
.hud-strip {
  grid-template-columns: 0.62fr 0.62fr 0.62fr 0.62fr 0.95fr 1fr 0.95fr 0.82fr;
}

.timer-state .hud-value {
  color: #175cd3;
}

.timer-state .hud-value.urgent {
  color: #b42318;
  animation: urgentTimerPulse 520ms ease-in-out infinite alternate;
}

@keyframes urgentTimerPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.12);
  }
}

.selection-state .hud-value {
  color: #16803c;
}

@media (max-width: 820px), (max-height: 560px) {
  .hud-strip {
    grid-template-columns: 0.54fr 0.54fr 0.54fr 0.54fr 0.86fr 0.9fr 0.86fr 0.76fr;
  }
}

/* PATCH: stat choice after selection points */
.stat-choice-screen {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: var(--card-w) minmax(260px, 1fr);
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.stat-choice-card {
  justify-self: center;
}

.stat-choice-panel {
  min-width: 0;
  background: #f8fafc;
  border: 1px solid #eaecf0;
  border-radius: 18px;
  padding: 1rem;
}

.stat-choice-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}

.stat-choice-panel p {
  margin: 0 0 0.75rem;
  color: #475467;
  font-weight: 750;
  font-size: 0.85rem;
}

.stat-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.stat-choice-button {
  min-height: 58px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
}

.stat-choice-button span {
  font-weight: 900;
}

.stat-choice-button strong {
  font-size: 1.3rem;
  font-weight: 950;
}

.selection-state .hud-value {
  font-size: 0.68rem;
}

@media (max-width: 820px), (max-height: 560px) {
  .stat-choice-screen {
    grid-template-columns: var(--card-w) minmax(200px, 1fr);
    gap: 0.65rem;
  }

  .stat-choice-panel {
    padding: 0.7rem;
  }

  .stat-choice-panel h2 {
    font-size: 0.9rem;
  }

  .stat-choice-panel p {
    font-size: 0.7rem;
  }

  .stat-choice-grid {
    gap: 0.45rem;
  }

  .stat-choice-button {
    min-height: 44px;
  }

  .selection-state .hud-value {
    font-size: 0.54rem;
  }
}

/* PATCH: Next Round overlay one-third down with countdown */
.overlay-controls {
  place-items: start center;
  padding-top: 33%;
}

.overlay-controls button {
  transform: translateY(-50%);
}

.overlay-controls button:hover:not(:disabled) {
  transform: translateY(calc(-50% - 1px));
}

#nextRoundButton {
  min-width: 190px;
}

/* PATCH: 5-second battle-stat choice countdown */
.stat-choice-countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 0.75rem;
  min-width: 112px;
  border-radius: 999px;
  padding: 0.38rem 0.68rem;
  background: #eef4ff;
  border: 1px solid #d1e0ff;
  color: #175cd3;
  font-weight: 950;
  font-size: 0.9rem;
}

.stat-choice-countdown.urgent {
  background: #fff1f3;
  border-color: #fecdd6;
  color: #b42318;
  animation: urgentTimerPulse 520ms ease-in-out infinite alternate;
}

/* PATCH: player/AI card-pool HUD counters */
.hud-strip {
  grid-template-columns: 0.55fr 0.55fr 0.65fr 0.65fr 0.55fr 0.55fr 0.88fr 0.9fr 0.86fr 0.72fr;
}

.card-count-state .hud-value {
  color: #7a2e0e;
}

@media (max-width: 820px), (max-height: 560px) {
  .hud-strip {
    grid-template-columns: 0.48fr 0.48fr 0.56fr 0.56fr 0.48fr 0.48fr 0.78fr 0.8fr 0.78fr 0.66fr;
  }

  .card-count-state .hud-label {
    font-size: 0.36rem;
  }
}

/* PATCH: main menu, guest identity, login exposure */
.hidden {
  display: none !important;
}

.main-menu-shell {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 150px);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(23, 92, 211, 0.24), transparent 30%),
    radial-gradient(circle at 80% 30%, rgba(22, 128, 60, 0.18), transparent 28%),
    #eef2f7;
  border: 10px solid #020617;
  border-radius: 32px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  padding: 18px;
  display: grid;
  place-items: center;
}

.main-menu-card {
  width: min(760px, 100%);
  max-height: 100%;
  overflow: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
  padding: clamp(1rem, 2vw, 1.4rem);
  display: grid;
  gap: 0.85rem;
}

.main-menu-heading {
  display: grid;
  gap: 0.28rem;
}

.eyebrow,
.panel-label {
  margin: 0;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.main-menu-subtitle {
  margin: 0;
  max-width: 54ch;
  color: #475467;
  font-weight: 750;
  font-size: 0.9rem;
}

.guest-panel,
.login-exposed-panel,
.multiplayer-panel {
  background: #f8fafc;
  border: 1px solid #eaecf0;
  border-radius: 18px;
  padding: 0.8rem;
}

.guest-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
}

.guest-panel strong {
  display: block;
  margin-top: 0.15rem;
  color: #172033;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.menu-actions button {
  min-height: 86px;
  padding: 0.9rem;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
}

.menu-actions button span {
  font-size: 1.1rem;
  font-weight: 950;
}

.menu-actions button small {
  margin-top: 0.18rem;
  opacity: 0.9;
  font-weight: 800;
}

.menu-primary {
  background: #175cd3;
}

.menu-secondary {
  background: #16803c;
}

.login-toggle {
  width: 100%;
}

.login-panel {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.login-panel label,
.room-actions label {
  display: grid;
  gap: 0.25rem;
  color: #475467;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.login-panel input,
.room-actions input {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  color: #172033;
  text-transform: none;
  letter-spacing: normal;
  background: white;
}

.login-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
}

.login-status {
  grid-column: 1 / -1;
  margin: 0;
  color: #667085;
  font-size: 0.8rem;
  font-weight: 750;
}

.multiplayer-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.multiplayer-panel p {
  margin: 0 0 0.7rem;
  color: #475467;
  font-weight: 750;
  font-size: 0.84rem;
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.6rem;
  align-items: end;
}

@media (max-width: 820px), (max-height: 560px) {
  .main-menu-shell {
    padding: 10px;
  }

  .main-menu-card {
    gap: 0.5rem;
    padding: 0.7rem;
    border-radius: 18px;
  }

  .main-menu-subtitle,
  .multiplayer-panel p,
  .login-status {
    font-size: 0.68rem;
  }

  .guest-panel,
  .login-exposed-panel,
  .multiplayer-panel {
    padding: 0.55rem;
    border-radius: 14px;
  }

  .guest-panel strong {
    font-size: 0.78rem;
  }

  .menu-actions {
    gap: 0.5rem;
  }

  .menu-actions button {
    min-height: 58px;
    border-radius: 14px;
    padding: 0.58rem;
  }

  .menu-actions button span {
    font-size: 0.88rem;
  }

  .menu-actions button small {
    font-size: 0.65rem;
  }

  .login-panel {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .login-panel input,
  .room-actions input {
    padding: 0.38rem 0.5rem;
    font-size: 0.72rem;
  }

  .room-actions {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.45rem;
  }
}

@media (max-width: 560px) {
  .menu-actions,
  .login-panel,
  .room-actions {
    grid-template-columns: 1fr;
  }

  .login-actions {
    flex-direction: column;
  }
}

/* PATCH: unmistakable browser-window version badge */
.browser-version-badge {
  position: fixed;
  top: 4px;
  left: 4px;
  z-index: 2147483647;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(16, 24, 40, 0.18);
  color: rgba(16, 24, 40, 0.86);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  pointer-events: none;
  user-select: none;
}


/* PATCH: guaranteed top-left browser version badge */
#browserVersionBadge.browser-version-badge {
  position: fixed !important;
  top: 4px !important;
  left: 4px !important;
  z-index: 2147483647 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}


/* PATCH: PHP-sourced version badge */
#browserVersionBadge.browser-version-badge {
  position: fixed !important;
  top: 4px !important;
  left: 4px !important;
  z-index: 2147483647 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
