@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/PlusJakartaSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/PlusJakartaSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/PlusJakartaSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/PlusJakartaSans-ExtraBold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --on-surface: #1e232a;
  --secondary: #5a5f67;
  --primary: #2e9b9d;
  --primary-deep: #006768;
  --primary-hover: #258284;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow: 0 4px 20px -2px rgba(30, 35, 42, 0.05);
  --radius: 1rem;
  --font-ui: "Plus Jakarta Sans", sans-serif;
  --font-grid: "Space Grotesk", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #ffffff;
  color: var(--on-surface);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
}

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: var(--bg);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.stage:has(.screen-home.is-active) {
  background: #ffffff;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: clamp(1rem, 2.5vw, 2.5rem);
}

.screen.is-active {
  display: flex;
}

.screen[hidden] {
  display: none !important;
}

.brand-bar {
  position: absolute;
  top: clamp(0.75rem, 2vw, 1.5rem);
  left: clamp(0.75rem, 2vw, 1.5rem);
}

.brand-logo {
  height: clamp(2.5rem, 6vh, 4rem);
  width: auto;
  object-fit: contain;
}

.brand-logo-sm {
  height: clamp(2rem, 4.5vh, 3rem);
  margin-bottom: 0.75rem;
}

.screen-home {
  background: linear-gradient(145deg, #f8ffff 0%, #ffffff 48%, #eefafa 100%);
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.8vw, 2.75rem);
  overflow: hidden;
}

.home-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 12%, rgba(46, 155, 157, 0.16) 0 9rem, transparent 9.1rem),
    radial-gradient(circle at 91% 88%, rgba(0, 103, 104, 0.11) 0 13rem, transparent 13.1rem),
    radial-gradient(ellipse 54% 55% at 50% 48%, rgba(255, 255, 255, 0.96), transparent 76%);
}

.home-content {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  width: min(100%, 62rem);
  max-height: 100%;
  padding: clamp(1.5rem, 3.2vw, 3rem) clamp(1.25rem, 5vw, 5rem);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.35rem, 2.6vh, 2rem);
  border: 1px solid rgba(46, 155, 157, 0.18);
  border-radius: clamp(1.5rem, 3vw, 2.5rem);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 28px 80px rgba(0, 103, 104, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  animation: home-enter 0.55s ease-out;
}

@keyframes home-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.home-logo-frame {
  position: relative;
  width: min(82vw, 38rem);
  aspect-ratio: 3.97 / 1;
  margin-bottom: clamp(1rem, 2vh, 1.35rem);
  overflow: hidden;
}

.home-logo {
  position: absolute;
  top: 0;
  left: 50%;
  width: 112.7%;
  height: auto;
  transform: translate(-50%, -30.1%);
}

.home-eyebrow {
  margin: 0 0 0.5rem;
  font-family: var(--font-grid);
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

.home-title {
  margin: 0;
  font-size: clamp(2.5rem, 5.4vw, 4.75rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.045em;
  color: var(--on-surface);
}

.home-action {
  width: min(100%, 38rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.25rem, 2.5vh, 1.75rem);
}

.home-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
}

.home-subtitle {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.5;
  color: var(--secondary);
  font-weight: 600;
}

.home-rules {
  margin: 0;
  width: 100%;
  padding: 0.85rem 1.15rem;
  border: 1px solid rgba(46, 155, 157, 0.18);
  border-radius: 0.9rem;
  background: rgba(239, 250, 250, 0.86);
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  line-height: 1.5;
  color: #3d4949;
}

.home-rules strong {
  color: var(--primary-deep);
  font-weight: 800;
}

.home-orientation {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #e8f7f7;
  color: var(--primary-deep);
  font-family: var(--font-grid);
  font-size: clamp(0.75rem, 1.25vw, 0.88rem);
  font-weight: 700;
  letter-spacing: 0.035em;
}

.home-orientation::before {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--primary);
  content: "";
}

.home-cta {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0.4rem 0;
}

.home-cta::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(100%, 22rem);
  height: 5.25rem;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(46, 155, 157, 0.22);
  filter: blur(18px);
  animation: home-cta-glow 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes home-cta-glow {
  0%,
  100% {
    opacity: 0.55;
    transform: translate(-50%, -50%) scale(0.92);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.home-play {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  cursor: pointer;
  width: min(100%, 22rem);
  min-height: 72px;
  padding: 1.15rem 2.75rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: clamp(1.25rem, 2.4vw, 1.55rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(180deg, #3aadb0 0%, #2e9b9d 45%, #217f81 100%);
  box-shadow:
    0 10px 28px rgba(46, 155, 157, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  animation: home-play-pulse 1.7s ease-in-out infinite;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.home-play:hover {
  animation: none;
  filter: brightness(1.05);
  transform: scale(1.03);
}

.home-play:active {
  transform: scale(0.98);
}

@keyframes home-play-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 10px 28px rgba(46, 155, 157, 0.38),
      0 0 0 0 rgba(46, 155, 157, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.28);
  }
  50% {
    transform: scale(1.045);
    box-shadow:
      0 14px 34px rgba(46, 155, 157, 0.48),
      0 0 0 14px rgba(46, 155, 157, 0),
      inset 0 1px 0 rgba(255, 255, 255, 0.28);
  }
}

.home-prize {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: -0.25rem;
  max-width: 38rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(46, 155, 157, 0.18);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.85);
  text-align: left;
}

.home-prize.is-hidden {
  display: none;
}

.home-prize .prize-image {
  width: 4rem;
  height: 4rem;
  border-radius: 0.65rem;
  object-fit: cover;
  flex-shrink: 0;
}

.home-prize .prize-image.is-hidden {
  display: none;
}

.home-prize .prize-text strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.1rem;
  color: var(--on-surface);
}

.home-prize .prize-text p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--secondary);
}

.eyebrow {
  margin: 0;
  font-family: var(--font-grid);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-deep);
}

.subtitle {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.125rem);
  color: var(--secondary);
  font-weight: 500;
}

.rules {
  margin: 0.25rem 0 0.5rem;
  padding: 0.85rem 1.25rem;
  background: #f2f4f6;
  border-radius: 0.75rem;
  font-size: 1rem;
  color: var(--on-surface);
}

.rules strong {
  color: var(--primary-deep);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 56px;
  padding: 0.95rem 2rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  transition: box-shadow 0.18s ease, filter 0.18s ease, transform 0.12s ease;
}

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

.btn-primary {
  background: linear-gradient(180deg, #3aadb0 0%, #2e9b9d 48%, #217f81 100%);
  color: #fff;
  box-shadow:
    0 10px 24px rgba(46, 155, 157, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow:
    0 13px 30px rgba(46, 155, 157, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.82);
  color: var(--primary-deep);
  border-color: rgba(46, 155, 157, 0.35);
}

.btn-secondary:hover {
  background: #effafa;
}

.prize-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0.4rem 0 0.75rem;
  padding: 1rem;
  background: rgba(239, 250, 250, 0.88);
  border: 1px solid rgba(46, 155, 157, 0.22);
  border-radius: 1rem;
  text-align: left;
}

.prize-card.is-hidden {
  display: none;
}

.prize-image {
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: 0.75rem;
  flex-shrink: 0;
}

.prize-image.is-hidden {
  display: none;
}

.prize-text strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.prize-text p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--secondary);
}

.screen-play {
  align-items: stretch;
  background: linear-gradient(145deg, #f8ffff 0%, #ffffff 48%, #eefafa 100%);
  padding: clamp(0.85rem, 1.8vw, 1.75rem);
  overflow: hidden;
}

.play-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at -2% 6%, rgba(46, 155, 157, 0.14) 0 10rem, transparent 10.1rem),
    radial-gradient(circle at 102% 96%, rgba(0, 103, 104, 0.11) 0 14rem, transparent 14.1rem);
}

.play-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: clamp(17rem, 25vw, 22rem) minmax(0, 1fr);
  gap: clamp(0.75rem, 1.6vw, 1.35rem);
  height: 100%;
  width: 100%;
  min-height: 0;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: clamp(0.8rem, 1.7vh, 1.15rem);
  min-height: 0;
  padding: clamp(1rem, 1.7vw, 1.5rem);
  border: 1px solid rgba(46, 155, 157, 0.18);
  border-radius: clamp(1.2rem, 2vw, 1.75rem);
  background: rgba(255, 255, 255, 0.84);
  box-shadow:
    0 22px 60px rgba(0, 103, 104, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.hud-brand {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.hud-logo-frame {
  position: relative;
  width: min(100%, 17rem);
  aspect-ratio: 3.97 / 1;
  overflow: hidden;
}

.hud-logo {
  position: absolute;
  top: 0;
  left: 50%;
  width: 112.7%;
  height: auto;
  transform: translate(-50%, -30.1%);
}

.hud-heading {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.round-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.play-title {
  margin: 0;
  font-size: clamp(1.65rem, 2.4vw, 2.25rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--on-surface);
}

.round-label {
  align-self: flex-start;
  margin: 0;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: #e8f7f7;
  font-family: var(--font-grid);
  font-size: clamp(0.72rem, 1vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--primary-deep);
}

.orientation-label {
  margin: 0;
  padding: 0.4rem 0.65rem;
  border: 1px solid rgba(46, 155, 157, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--secondary);
  font-size: clamp(0.65rem, 0.85vw, 0.75rem);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 0.65rem;
}

.stat-row {
  display: flex;
  min-width: 0;
  min-height: 5.2rem;
  padding: 0.75rem 0.85rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.25rem;
  border: 1px solid rgba(46, 155, 157, 0.16);
  border-radius: 1rem;
  background: rgba(239, 250, 250, 0.78);
}

.stat-label {
  font-family: var(--font-grid);
  font-size: clamp(0.68rem, 0.9vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
}

.stat-value {
  font-size: clamp(1.75rem, 2.7vw, 2.35rem);
  font-weight: 800;
  line-height: 1;
  color: var(--on-surface);
}

.timer-value {
  font-family: var(--font-grid);
  font-size: clamp(1.65rem, 2.8vw, 2.35rem);
  font-weight: 700;
  line-height: 1;
  color: var(--primary-deep);
  letter-spacing: 0.02em;
}

.timer-row.is-urgent .timer-value {
  color: var(--warning);
}

.timer-row.is-urgent {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.34);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.08);
}

.word-bank {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  flex: 1;
}

.word-bank-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.word-bank-hint {
  font-size: 0.68rem;
  font-weight: 600;
  color: #7a838b;
}

.word-list {
  list-style: none;
  margin: 0;
  padding: 0 0.15rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 155, 157, 0.35) transparent;
}

.word-list li {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 2.55rem;
  padding: 0.55rem 2.2rem 0.55rem 0.8rem;
  border: 1px solid rgba(203, 213, 225, 0.78);
  border-radius: 0.8rem;
  background: rgba(248, 250, 252, 0.86);
  font-size: clamp(0.82rem, 1.15vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.055em;
  color: #384047;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.word-list li::after {
  position: absolute;
  right: 0.75rem;
  display: grid;
  width: 1.15rem;
  height: 1.15rem;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  content: "";
  font-size: 0.72rem;
  line-height: 1;
}

.word-list li.pending {
  border-color: rgba(203, 213, 225, 0.78);
}

.word-list li.found {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #a7f3d0;
}

.word-list li.found::after {
  content: "✓";
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.word-list li.missed {
  background: #ffdad6;
  color: #93000a;
  border-color: #f5b5b0;
}

.word-list li.missed::after {
  content: "!";
  border-color: #ba1a1a;
  background: #ba1a1a;
  color: #fff;
}

.grid-panel {
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: clamp(0.75rem, 1.3vw, 1.2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(46, 155, 157, 0.18);
  border-radius: clamp(1.2rem, 2vw, 1.75rem);
  background: rgba(255, 255, 255, 0.84);
  box-shadow:
    0 22px 60px rgba(0, 103, 104, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.word-grid {
  --cell-gap: clamp(0.16rem, 0.38vw, 0.38rem);
  display: grid;
  flex: none;
  gap: var(--cell-gap);
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
}

.grid-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1.5px solid #e6edf0;
  border-radius: clamp(0.25rem, 0.65vw, 0.55rem);
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 2px 7px rgba(30, 35, 42, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-family: var(--font-grid);
  font-weight: 700;
  font-size: clamp(0.8rem, 1.45vw, 1.3rem);
  line-height: 1;
  color: var(--on-surface);
  min-width: 0;
  min-height: 0;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease,
    box-shadow 0.12s ease;
}

.grid-cell.is-selected {
  z-index: 1;
  background: linear-gradient(145deg, #3aadb0, #23888a);
  border-color: #187577;
  color: #fff;
  box-shadow:
    0 0 0 2px rgba(46, 155, 157, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.grid-cell.is-found {
  background: linear-gradient(145deg, #ecfdf5, #d7f8e8);
  border-color: var(--success);
  color: var(--success-text);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.16);
}

.grid-cell.is-missed {
  background: #ffe3df;
  border-color: #ba1a1a;
  color: #93000a;
  animation: missed-pulse 0.55s ease;
}

@keyframes missed-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(186, 26, 26, 0); }
  45% { box-shadow: inset 0 0 0 3px rgba(186, 26, 26, 0.24); }
}

.word-grid[data-size="6"] .grid-cell,
.word-grid[data-size="7"] .grid-cell,
.word-grid[data-size="8"] .grid-cell,
.word-grid[data-size="9"] .grid-cell,
.word-grid[data-size="10"] .grid-cell {
  font-size: clamp(1rem, 2.25vw, 1.7rem);
}

.word-grid[data-size="15"] .grid-cell,
.word-grid[data-size="16"] .grid-cell,
.word-grid[data-size="17"] .grid-cell {
  font-size: clamp(0.72rem, 1.22vw, 1.05rem);
}

.word-grid[data-size="18"] .grid-cell,
.word-grid[data-size="19"] .grid-cell,
.word-grid[data-size="20"] .grid-cell {
  border-width: 1px;
  border-radius: clamp(0.15rem, 0.42vw, 0.35rem);
  font-size: clamp(0.62rem, 1vw, 0.88rem);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: clamp(1.25rem, 3vw, 2.5rem);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.15rem 0.75rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: rgba(6, 95, 70, 0.94);
  box-shadow: 0 14px 34px rgba(6, 95, 70, 0.3);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  z-index: 20;
  backdrop-filter: blur(10px);
  animation: toast-enter 0.22s ease-out;
}

.toast[hidden] {
  display: none;
}

.toast-mark {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--success-text);
}

@keyframes toast-enter {
  from { opacity: 0; transform: translate(-50%, 0.6rem); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 49, 52, 0.58);
  backdrop-filter: blur(10px);
  z-index: 30;
  padding: clamp(1rem, 3vw, 2rem);
}

.overlay[hidden] {
  display: none !important;
}

.overlay-card {
  --overlay-accent: var(--primary);
  position: relative;
  width: min(100%, 35rem);
  overflow: hidden;
  padding: clamp(1.5rem, 3.5vw, 2.6rem);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: clamp(1.4rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  box-shadow: 0 28px 70px rgba(3, 38, 40, 0.28);
  animation: overlay-card-enter 0.28s ease-out;
}

.overlay-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 0.38rem;
  background: var(--overlay-accent);
  content: "";
}

.overlay-card.is-success,
.overlay-card.is-win {
  --overlay-accent: var(--success);
}

.overlay-card.is-timeout {
  --overlay-accent: var(--warning);
}

.overlay-card.is-loss {
  --overlay-accent: #d45b52;
}

.overlay-symbol {
  display: grid;
  width: 4.25rem;
  height: 4.25rem;
  margin: 0 auto 1rem;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--overlay-accent) 13%, white);
  color: var(--overlay-accent);
  font-family: var(--font-grid);
  font-size: 2rem;
  font-weight: 700;
}

.overlay-symbol::before {
  content: "✓";
}

.overlay-card.is-timeout .overlay-symbol::before,
.overlay-card.is-loss .overlay-symbol::before {
  content: "!";
}

.overlay-eyebrow {
  margin: 0 0 0.55rem !important;
  color: var(--overlay-accent) !important;
  font-family: var(--font-grid);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.overlay-card h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.75rem, 3.5vw, 2.65rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--on-surface);
}

.overlay-card p {
  margin: 0 0 1.3rem;
  font-size: clamp(0.95rem, 1.6vw, 1.08rem);
  line-height: 1.55;
  color: var(--secondary);
}

.result-score {
  margin-bottom: 0.5rem !important;
  font-family: var(--font-grid);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem) !important;
  font-weight: 800 !important;
  color: var(--primary-deep) !important;
  letter-spacing: 0.025em;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 0.65rem;
}

.overlay-actions .btn,
.overlay-round-card .btn {
  min-width: min(100%, 14rem);
}

.overlay-actions .is-hidden {
  display: none !important;
}

@keyframes overlay-card-enter {
  from { opacity: 0; transform: translateY(0.75rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1050px) and (min-width: 701px) {
  .play-layout {
    grid-template-columns: clamp(14rem, 29vw, 18rem) minmax(0, 1fr);
  }

  .hud {
    padding: 0.85rem;
    gap: 0.65rem;
  }

  .hud-logo-frame {
    width: min(100%, 13rem);
  }

  .play-title {
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  }

  .stat-row {
    min-height: 4.35rem;
    padding: 0.55rem 0.65rem;
  }

  .word-list {
    gap: 0.3rem;
  }

  .word-list li {
    min-height: 2rem;
    padding-top: 0.38rem;
    padding-bottom: 0.38rem;
  }
}

@media (max-width: 700px), (orientation: portrait) {
  .stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  .screen-home {
    padding: 0.8rem;
  }

  .screen-play {
    padding: 0.65rem;
  }

  .play-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.65rem;
  }

  .hud {
    display: grid;
    grid-template-areas:
      "brand stats"
      "words words";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding: 0.75rem;
    border-radius: 1.1rem;
  }

  .hud-brand {
    grid-area: brand;
    min-width: 0;
    gap: 0.4rem;
  }

  .hud-logo-frame {
    width: min(100%, 10.5rem);
  }

  .hud-heading {
    gap: 0.3rem;
  }

  .play-title {
    font-size: clamp(1.15rem, 5.4vw, 1.45rem);
  }

  .round-label {
    padding: 0.28rem 0.48rem;
    font-size: 0.62rem;
  }

  .orientation-label {
    padding: 0.28rem 0.48rem;
    font-size: 0.58rem;
  }

  .stats-grid {
    grid-area: stats;
    grid-template-columns: repeat(2, minmax(4rem, 1fr));
    align-self: stretch;
    gap: 0.4rem;
  }

  .stat-row {
    min-height: 0;
    padding: 0.5rem;
    border-radius: 0.75rem;
  }

  .stat-label {
    font-size: 0.56rem;
  }

  .stat-value,
  .timer-value {
    font-size: clamp(1.18rem, 5vw, 1.45rem);
  }

  .word-bank {
    grid-area: words;
    gap: 0.42rem;
  }

  .word-bank-hint {
    display: none;
  }

  .word-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
    overflow: visible;
  }

  .word-list li {
    flex: 1 1 calc(33.333% - 0.35rem);
    min-width: 6.3rem;
    min-height: 1.9rem;
    padding: 0.34rem 1.55rem 0.34rem 0.55rem;
    border-radius: 0.6rem;
    font-size: clamp(0.63rem, 2.7vw, 0.75rem);
  }

  .word-list li::after {
    right: 0.45rem;
    width: 0.9rem;
    height: 0.9rem;
    font-size: 0.55rem;
  }

  .grid-panel {
    padding: clamp(0.5rem, 2vw, 0.75rem);
    border-radius: 1.1rem;
  }

  .word-grid {
    width: 100%;
    height: auto;
    --cell-gap: clamp(0.1rem, 0.75vw, 0.25rem);
  }

  .grid-cell {
    font-size: clamp(0.64rem, 3vw, 0.92rem);
    border-width: 1px;
  }

  .word-grid[data-size="6"] .grid-cell,
  .word-grid[data-size="7"] .grid-cell,
  .word-grid[data-size="8"] .grid-cell,
  .word-grid[data-size="9"] .grid-cell,
  .word-grid[data-size="10"] .grid-cell {
    font-size: clamp(0.85rem, 4.2vw, 1.2rem);
  }

  .word-grid[data-size="18"] .grid-cell,
  .word-grid[data-size="19"] .grid-cell,
  .word-grid[data-size="20"] .grid-cell {
    font-size: clamp(0.48rem, 2.1vw, 0.65rem);
  }

  .overlay-card {
    padding: 1.5rem 1rem;
  }

  .overlay-symbol {
    width: 3.6rem;
    height: 3.6rem;
    margin-bottom: 0.8rem;
    font-size: 1.65rem;
  }

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

  .overlay-actions .btn,
  .overlay-round-card .btn {
    width: 100%;
  }

  .home-content {
    padding: clamp(1.35rem, 6vw, 2rem) clamp(1rem, 5vw, 1.5rem);
    gap: clamp(1.1rem, 3vh, 1.5rem);
    border-radius: 1.5rem;
  }

  .home-logo-frame {
    width: min(86vw, 31rem);
    margin-bottom: 1rem;
  }

  .home-title {
    font-size: clamp(2.5rem, 13vw, 4rem);
  }

  .home-play {
    width: min(100%, 20rem);
  }
}

@media (max-height: 680px) and (min-width: 701px) {
  .home-content {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    gap: 1rem;
  }

  .home-logo-frame {
    width: min(70vw, 31rem);
    margin-bottom: 0.75rem;
  }

  .home-action {
    gap: 0.85rem;
  }

  .home-copy {
    gap: 0.5rem;
  }

  .home-play {
    min-height: 60px;
  }

  .screen-play {
    padding: 0.7rem;
  }

  .play-layout {
    grid-template-columns: clamp(14rem, 25vw, 17rem) minmax(0, 1fr);
    gap: 0.65rem;
  }

  .hud {
    padding: 0.7rem;
    gap: 0.5rem;
  }

  .hud-brand,
  .hud-heading {
    gap: 0.3rem;
  }

  .hud-logo-frame {
    width: min(100%, 11.5rem);
  }

  .play-title {
    font-size: 1.35rem;
  }

  .round-label {
    padding: 0.25rem 0.45rem;
    font-size: 0.62rem;
  }

  .orientation-label {
    padding: 0.25rem 0.45rem;
    font-size: 0.56rem;
  }

  .stat-row {
    min-height: 3.6rem;
    padding: 0.4rem 0.55rem;
  }

  .stat-value,
  .timer-value {
    font-size: 1.45rem;
  }

  .word-bank {
    gap: 0.3rem;
  }

  .word-list {
    gap: 0.22rem;
  }

  .word-list li {
    min-height: 1.75rem;
    padding: 0.25rem 1.8rem 0.25rem 0.55rem;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.home-play:focus-visible,
.btn:focus-visible,
.word-grid:focus-visible {
  outline: 3px solid rgba(46, 155, 157, 0.46);
  outline-offset: 4px;
}
