@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/PressStart2P-Regular.ttf") format("truetype");
}

:root {
  color-scheme: dark;
  --bg: #061024;
  --surface: rgba(8, 20, 42, 0.92);
  --surface-2: rgba(20, 48, 87, 0.88);
  --ink: #eef7ff;
  --muted: #9ab2cc;
  --line: rgba(115, 192, 255, 0.28);
  --green: #34d47f;
  --green-bg: #087a4e;
  --yellow: #e0b72f;
  --yellow-bg: #3a300f;
  --red: #e8695e;
  --red-bg: #3b1718;
  --teal: #55aaff;
  --gold: #ffca49;
  --cyan: #6ed7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42), 0 0 34px rgba(85, 170, 255, 0.14);
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  font-family:
    var(--font-pixel);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(110, 180, 255, 0.052) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 180, 255, 0.052) 1px, transparent 1px),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, #061024 0%, #0a1e3a 48%, #10162b 100%),
    var(--bg);
  background-size: 38px 38px, 38px 38px, auto, auto, auto;
  color: var(--ink);
  font-family: var(--font-pixel);
  line-height: 1.45;
  -webkit-font-smoothing: none;
  font-synthesis: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 44px;
}

.ad-rail {
  position: fixed;
  z-index: 1;
  top: 112px;
  display: block;
  width: 250px;
  height: 600px;
  overflow: hidden;
}

.ad-rail-left {
  left: calc((100vw - 1420px) / 4);
}

.ad-rail-right {
  right: calc((100vw - 1420px) / 4);
}

.ad-rail .adsbygoogle {
  display: inline-block;
  width: 250px;
  height: 600px;
}

.topbar {
  position: relative;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 0 58px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
  text-shadow: 0 0 16px rgba(110, 180, 255, 0.28);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.language-toggle {
  position: absolute;
  top: 2px;
  right: 0;
  display: inline-grid;
  min-width: 48px;
  min-height: 36px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #f2f8ff;
  color: #061024;
  box-shadow: 3px 3px 0 var(--ink), 0 0 18px rgba(110, 180, 255, 0.24);
  font-size: 0.68rem;
  font-weight: 900;
}

.language-toggle:focus-visible {
  outline: 3px solid rgba(110, 180, 255, 0.38);
  outline-offset: 3px;
}

.pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 12, 27, 0.78);
  padding: 6px 12px;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
}

.pill-muted {
  color: #d6ecff;
}

.game-layout {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 14px;
  align-items: start;
}

.play-panel,
.side-panel {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.play-panel {
  position: relative;
  padding: 18px 0 20px;
  overflow: hidden;
}

.play-panel::before {
  display: none;
  content: none;
}

.side-panel {
  display: grid;
  max-width: 560px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 0 0;
  background: transparent;
  box-shadow: none;
}

.title-row {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 0 52px;
  text-align: center;
}

.title-row > div {
  min-width: 0;
  width: 100%;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.05rem;
  line-height: 1.2;
  overflow-wrap: break-word;
  text-wrap: balance;
}

h2 {
  font-size: 0.95rem;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 14, 31, 0.82);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(110, 180, 255, 0.1);
}

.title-row .icon-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(100%, 560px);
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 12px;
}

.combo {
  position: relative;
  min-width: 0;
}

.guess-form input {
  width: 100%;
  min-width: 0;
  border: 2px solid rgba(199, 255, 242, 0.72);
  border-radius: 8px;
  background: rgba(4, 12, 27, 0.86);
  padding: 14px 16px;
  color: var(--ink);
  font-size: 0.68rem;
  line-height: 1.45;
  outline: none;
}

.guess-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(110, 180, 255, 0.16), 0 0 28px rgba(85, 170, 255, 0.2);
}

.guess-form button {
  border: 2px solid rgba(239, 255, 249, 0.9);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  padding: 12px 18px;
  color: #061024;
  font-size: 0.68rem;
  line-height: 1.45;
  font-weight: 900;
}

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  max-height: 312px;
  overflow-y: auto;
  border: 2px solid rgba(199, 255, 242, 0.72);
  border-radius: 8px;
  background: rgba(7, 17, 35, 0.98);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36), 0 0 28px rgba(110, 180, 255, 0.16);
  padding: 6px;
}

.suggestions[hidden] {
  display: none;
}

.guess-form .suggestion-item {
  display: grid;
  width: 100%;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 7px;
  color: var(--ink);
  text-align: left;
}

.guess-form .suggestion-item:hover,
.guess-form .suggestion-item[aria-selected="true"] {
  background: var(--surface-2);
}

.suggestion-thumb,
.suggestion-fallback {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f8ff;
}

.suggestion-thumb img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.suggestion-fallback {
  color: var(--teal);
  font-size: 0.58rem;
  font-weight: 900;
}

.suggestion-name {
  display: block;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.54rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message {
  text-align: center;
  min-height: 24px;
  margin: 0 0 10px;
  color: #c8fff3;
  font-size: 0.64rem;
  font-weight: 700;
}

.board-wrap {
  width: 100%;
  overflow-x: hidden;
  padding-bottom: 4px;
}

.guess-table {
  --tile-size: clamp(58px, calc((100vw - 84px) / 8), 104px);
  width: max-content;
  min-width: 0;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 5px 10px;
  table-layout: fixed;
}

.guess-table th {
  width: var(--tile-size);
  padding: 0 2px 2px;
  color: #c8e7ff;
  font-size: clamp(0.34rem, 0.72vw, 0.48rem);
  font-weight: 900;
  line-height: 1.28;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.guess-table td {
  width: var(--tile-size);
  min-width: var(--tile-size);
  max-width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid rgba(115, 192, 255, 0.26);
  border-radius: 10px;
  padding: clamp(3px, 0.7vw, 6px);
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.05), 0 0 18px rgba(0, 0, 0, 0.12);
  font-size: clamp(0.38rem, 0.9vw, 0.54rem);
  font-weight: 900;
  line-height: 1.34;
  text-align: center;
  vertical-align: middle;
  overflow: hidden;
}

.guess-table td:first-child {
  padding: 0;
}

.guess-row.is-revealing .reveal-cell {
  animation: reveal-cell 720ms cubic-bezier(0.2, 0.82, 0.22, 1) forwards;
  animation-delay: calc(var(--reveal-index) * 250ms);
  opacity: 0;
  transform: translateY(-8px) rotateX(-82deg) scale(0.96);
  transform-origin: top center;
  will-change: opacity, transform;
}

.guess-row.is-winning .reveal-cell {
  animation:
    reveal-cell 720ms cubic-bezier(0.2, 0.82, 0.22, 1) forwards,
    correct-cell-celebration 900ms ease-out forwards;
  animation-delay:
    calc(var(--reveal-index) * 250ms),
    2850ms;
}

@keyframes reveal-cell {
  0% {
    opacity: 0;
    transform: translateY(-8px) rotateX(-82deg) scale(0.96);
  }

  62% {
    opacity: 1;
    transform: translateY(1px) rotateX(8deg) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateY(0) rotateX(0deg) scale(1);
  }
}

@keyframes correct-cell-celebration {
  0% {
    filter: brightness(1);
    transform: translateY(0) rotateX(0deg) scale(1);
  }

  34% {
    filter: brightness(1.28);
    box-shadow:
      inset 0 -2px 0 rgba(255, 255, 255, 0.16),
      0 0 18px rgba(52, 212, 127, 0.42),
      0 0 32px rgba(52, 212, 127, 0.28);
    transform: translateY(-2px) rotateX(0deg) scale(1.055);
  }

  68% {
    filter: brightness(1.08);
    transform: translateY(1px) rotateX(0deg) scale(0.99);
  }

  100% {
    filter: brightness(1);
    transform: translateY(0) rotateX(0deg) scale(1);
  }
}

.cell-image {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: center;
  justify-items: center;
}

.cell-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.32));
}

.cell-content {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  align-content: center;
  gap: 3px;
  text-align: center;
  hyphens: none;
  overflow-wrap: normal;
  word-break: normal;
}

.cell-value,
.cell-note {
  position: relative;
  z-index: 1;
}

.cell-value-medium {
  font-size: clamp(0.32rem, 0.72vw, 0.48rem);
  line-height: 1.24;
}

.cell-value-long {
  font-size: clamp(0.28rem, 0.62vw, 0.4rem);
  line-height: 1.18;
}

.debut-content {
  overflow: hidden;
}

.debut-arrow {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  color: currentColor;
  width: calc(var(--tile-size) * 0.88);
  height: calc(var(--tile-size) * 0.82);
  background: currentColor;
  clip-path: polygon(50% 0, 100% 42%, 78% 42%, 78% 100%, 22% 100%, 22% 42%, 0 42%);
  opacity: 0.2;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.debut-arrow.down {
  transform: translate(-50%, -50%) rotate(180deg);
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #f2f8ff;
  color: #061024;
  font-size: 0.58rem;
  font-weight: 900;
}

.correct {
  background: var(--green-bg);
  border-color: rgba(52, 212, 127, 0.68);
  color: #eafff5;
}

.partial {
  background: var(--yellow-bg);
  border-color: rgba(255, 202, 73, 0.62);
  color: #ffe7a5;
}

.wrong {
  background: var(--red-bg);
  border-color: rgba(232, 105, 94, 0.6);
  color: #ffd0ca;
}

.hint {
  background: #142337;
  border-color: rgba(110, 180, 255, 0.42);
  color: #d1f7ff;
}

.cell-note {
  display: block;
  font-size: 0.45rem;
  line-height: 1.24;
  color: inherit;
  overflow-wrap: normal;
  opacity: 0.72;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 170px;
  margin: 2px auto 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(110, 180, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 180, 255, 0.045) 1px, transparent 1px),
    rgba(8, 24, 48, 0.46);
  background-size: 22px 22px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.empty-state[hidden] {
  display: none;
}

.empty-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 12, 27, 0.86);
  color: var(--teal);
  font-size: 1.1rem;
  font-weight: 900;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 12, 27, 0.76);
  padding: 12px;
}

.score-card {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  padding: 4px 8px;
  text-align: center;
}

.score-card strong {
  font-size: 1.2rem;
  line-height: 1;
}

.score-label {
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  text-align: center;
}

.result-card[hidden] {
  display: none;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.answer-portrait {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  margin: 0 auto;
  border: 2px solid rgba(115, 192, 255, 0.34);
  border-radius: 10px;
  background: #f2f8ff;
  box-shadow: 0 0 18px rgba(110, 180, 255, 0.16);
}

.answer-portrait:empty {
  display: none;
}

.answer-portrait img {
  display: block;
  width: 86px;
  height: 86px;
  object-fit: contain;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.28));
}

.answer-portrait .avatar {
  width: 64px;
  height: 64px;
}

#answer-name {
  font-size: 0.95rem;
}

.help-dialog {
  width: min(480px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  background: #061024;
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 0;
}

.help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.help-dialog form {
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.legend-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px 12px;
  align-items: center;
}

.legend-grid p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.legend-chip {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.58rem;
  font-weight: 900;
  text-align: center;
}

.celebration-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.celebration-piece {
  position: absolute;
  top: 30%;
  left: 50%;
  color: var(--color);
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0;
  text-shadow: 0 0 12px currentColor;
  transform: translate(-50%, -50%) scale(0.4);
  animation: celebration-burst var(--dur) cubic-bezier(0.12, 0.78, 0.28, 1) forwards;
  animation-delay: var(--delay);
  will-change: opacity, transform;
}

.celebration-piece.confetti {
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: var(--color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--color), transparent 35%);
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 20px;
  color: rgba(214, 236, 255, 0.72);
  font-size: 0.46rem;
  line-height: 1.6;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer strong {
  color: #eaf7ff;
  font-weight: 900;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.social-link {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #dff5ff;
  text-decoration: none;
  transition:
    color 160ms ease,
    transform 160ms ease;
}

.social-link:hover,
.social-link:focus-visible {
  color: #6ed7ff;
  transform: translateY(-2px) scale(1.04);
}

.social-link:focus-visible {
  outline: 3px solid rgba(110, 180, 255, 0.26);
  outline-offset: 3px;
}

.social-link svg {
  display: block;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.social-link path {
  fill: currentColor;
  stroke: none;
}

@keyframes celebration-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(0turn);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.05) rotate(var(--r));
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 820px);
    padding-top: 14px;
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1484px) {
  .ad-rail {
    display: none;
  }
}

@media (max-width: 560px) {
  .guess-table {
    --tile-size: calc((100vw - 52px) / 8);
    border-spacing: 3px 8px;
  }

  .guess-table td {
    border-width: 1px;
    border-radius: 7px;
  }

  .guess-table th {
    font-size: 0.28rem;
  }

  .topbar {
    padding: 0 50px;
  }

  .brand {
    font-size: 1.28rem;
  }

  .language-toggle {
    min-width: 42px;
    min-height: 34px;
    font-size: 0.58rem;
  }

  .play-panel {
    padding: 16px 0 18px;
  }

  .title-row {
    gap: 10px;
    padding: 0 44px;
  }

  .title-row .icon-button {
    width: 36px;
    height: 36px;
  }

  h1 {
    font-size: 1.28rem;
  }

  .guess-form {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .score-card strong {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .celebration-layer {
    display: none;
  }

  .guess-row.is-revealing .reveal-cell {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
