:root {
  --page: #181b22;
  --surface: #22252e;
  --surface-raised: #2a2e38;
  --ink: #f1f1f4;
  --muted: rgba(241, 241, 244, 0.6);
  --accent: #2fbfa3;
  --accent-hover: #4dd3b8;
  --accent-soft: #7fdcc9;
  --correct: #23a68d;
  --correct-glow: rgba(35, 166, 141, 0.28);
  --present: #e0a13a;
  --absent: #485062;
  --mark-ink: #0f1a19;
  --header-height: 58px;
  --footer-height: 24px;
  --viewport-height: 100vh;
}

body.high-contrast {
  --correct: #3b82f6;
  --correct-glow: rgba(59, 130, 246, 0.3);
  --present: #f97316;
  --absent: #3b404c;
  --mark-ink: #0b0f18;
}

@supports (height: 100svh) {
  :root {
    --viewport-height: 100svh;
  }
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 50% 20%, #232836, var(--page) 70%) no-repeat, var(--page);
  background-size: 100% var(--viewport-height), auto;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
  user-select: none;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.home-link {
  position: relative;
  display: flex;
  align-items: center;
  padding-right: 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  transition: opacity 0.15s;
}

.home-link:hover {
  opacity: 0.8;
}

.home-link-mark {
  display: block;
  width: 30px;
  height: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--mark-ink);
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 6px;
  margin: 0;
}

.stat {
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
}

.stat-value {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.mode-picker {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: block;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
  opacity: 0.7;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.mode-option:hover span {
  opacity: 1;
}

.mode-option input:checked + span {
  background: var(--ink);
  color: #1d1d27;
  opacity: 1;
}

.mode-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.new-game-button {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--mark-ink);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s, transform 0.1s;
}

.new-game-button:hover {
  background: var(--accent-hover);
}

.new-game-button:active {
  transform: scale(0.96);
}

kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
}

.ghost-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  opacity: 0.85;
}

.ghost-button:hover,
.ghost-button[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

.settings {
  position: relative;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 4px;
  width: 250px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.settings-panel[hidden] {
  display: none;
}

.setting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.setting:hover {
  background: rgba(255, 255, 255, 0.06);
}

.setting input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.setting:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.7;
}

.setting-note {
  margin: 0;
  padding: 0 8px 6px 34px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.setting-note[hidden] {
  display: none;
}

#table {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--viewport-height) - var(--header-height) - var(--footer-height));
  padding: 20px 16px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.play-area {
  --keyboard-height: 186px;
  --tile-gap: 6px;
  --tile-size: min(62px, calc((100vw - 48px) / 5 - var(--tile-gap)), calc((var(--viewport-height) - var(--header-height) - var(--footer-height) - var(--keyboard-height) - 110px) / 6 - var(--tile-gap)));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.status {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

.board-wrap {
  position: relative;
}

.board {
  display: grid;
  gap: var(--tile-gap);
}

.row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: var(--tile-gap);
}

.row.is-shaking {
  animation: row-shake 0.45s ease;
}

.tile {
  display: grid;
  place-items: center;
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  font-size: calc(var(--tile-size) * 0.5);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.tile[data-state="filled"] {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
}

.tile[data-state="correct"],
.tile[data-state="present"],
.tile[data-state="absent"] {
  border-color: transparent;
  color: var(--mark-ink);
}

.tile[data-state="correct"] {
  background: var(--correct);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.16), 0 6px 18px var(--correct-glow);
}

.tile[data-state="present"] {
  background: var(--present);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.tile[data-state="absent"] {
  background: var(--absent);
  color: rgba(241, 241, 244, 0.85);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.tile.is-popping {
  animation: tile-pop 0.12s ease-out;
}

.tile.is-flipping {
  animation: tile-turn 0.5s ease-in-out;
}

.tile.is-bouncing {
  animation: tile-hop 0.6s ease var(--bounce-delay, 0ms);
}

.toast {
  position: absolute;
  top: -8px;
  left: 50%;
  z-index: 10;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #16181e;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

.keyboard {
  display: grid;
  gap: 7px;
  width: min(520px, 100%);
  touch-action: manipulation;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 46px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #3a3e4b;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  text-transform: uppercase;
  transition: background 0.2s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.key:hover {
  background: #464b5a;
}

.key:active {
  transform: scale(0.94);
}

.key.is-wide {
  flex: 1.55 1 0;
  max-width: 72px;
  font-size: 13px;
  text-transform: none;
  display: grid;
  place-items: center;
}

.key[data-state="correct"] {
  background: var(--correct);
  color: var(--mark-ink);
}

.key[data-state="present"] {
  background: var(--present);
  color: var(--mark-ink);
}

.key[data-state="absent"] {
  background: #23262e;
  color: rgba(241, 241, 244, 0.38);
}

.key:focus-visible {
  outline: 2px solid var(--correct);
  outline-offset: 2px;
}

@keyframes row-shake {
  15%,
  55% {
    transform: translateX(-7px);
  }
  35%,
  75% {
    transform: translateX(7px);
  }
  90% {
    transform: translateX(-3px);
  }
}

@keyframes tile-pop {
  50% {
    transform: scale(1.08);
  }
}

@keyframes tile-turn {
  0% {
    transform: perspective(400px) rotateX(0);
  }
  50% {
    transform: perspective(400px) rotateX(-90deg);
  }
  100% {
    transform: perspective(400px) rotateX(0);
  }
}

@keyframes tile-hop {
  30% {
    transform: translateY(-14px);
  }
  55% {
    transform: translateY(2px);
  }
  75% {
    transform: translateY(-4px);
  }
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 11, 14, 0.6);
  backdrop-filter: blur(3px);
  animation: fade-in 0.25s ease-out;
}

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

.result-card {
  position: relative;
  width: min(380px, 100%);
  max-height: calc(var(--viewport-height) - 40px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: var(--surface-raised);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: card-rise 0.35s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.result-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  opacity: 0.7;
}

.result-close:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
}

.result-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.result-word {
  margin: 0 0 16px;
  font-size: 15px;
  opacity: 0.85;
}

.result-word strong {
  color: var(--correct);
  letter-spacing: 0.12em;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 16px;
}

.result-stat {
  padding: 7px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.result-stat dd {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.distribution {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
}

.distribution-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.distribution-label {
  width: 12px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.7;
}

.distribution-bar {
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--absent);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.distribution-bar.is-current {
  background: var(--correct);
  color: var(--mark-ink);
}

.result-note {
  margin: 0 0 14px;
  color: var(--present);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: grid;
  gap: 8px;
}

.action {
  height: 42px;
  border: 0;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 15px;
  font-weight: 700;
}

.action:hover {
  background: rgba(255, 255, 255, 0.13);
}

.action.primary {
  background: var(--correct);
  color: var(--mark-ink);
}

.action.primary:hover {
  filter: brightness(1.08);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

.dialog {
  width: min(360px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 24px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: var(--surface-raised);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  color: inherit;
  text-align: center;
}

.dialog[open] {
  animation: card-rise 0.3s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.dialog::backdrop {
  background: rgba(10, 11, 14, 0.6);
  backdrop-filter: blur(3px);
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.dialog p {
  margin: 0 0 18px;
  opacity: 0.7;
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
}

.dialog-actions .action {
  flex: 1;
  padding: 0 12px;
}
.site-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 10px;
  opacity: 0.7;
}

.site-footer a {
  color: inherit;
}


@media (max-width: 1100px) {
  header {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .button-label {
    display: none;
  }

  .new-game-button {
    width: 38px;
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 860px) {
  :root {
    --header-height: 104px;
  }
}

@media (max-width: 640px) {
  header {
    padding: 8px 12px;
    gap: 8px;
  }

  .header-start {
    gap: 10px;
  }

  .home-link {
    padding-right: 10px;
  }

  .brand-mark {
    display: none;
  }

  h1 {
    font-size: 17px;
  }

  .stat {
    min-width: 58px;
    padding: 4px 8px;
  }

  .stat-value {
    font-size: 14px;
  }

  .controls {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  .mode-option span {
    padding: 6px 12px;
  }

  #table {
    padding: 10px 6px 12px;
  }

  .play-area {
    --keyboard-height: 176px;
    --tile-gap: 5px;
    gap: 10px;
  }

  .keyboard {
    gap: 6px;
  }

  .keyboard-row {
    gap: 4px;
  }

  .key {
    height: 54px;
    border-radius: 8px;
    font-size: 16px;
  }

  .key.is-wide {
    font-size: 12px;
  }

  .tile {
    border-radius: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row.is-shaking,
  .tile.is-popping,
  .tile.is-flipping,
  .tile.is-bouncing,
  .result-overlay,
  .result-card {
    animation: none;
  }

  .key {
    transition: none;
  }
}
.guide {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  color: rgba(241, 241, 244, 0.84);
  font-size: 16px;
  line-height: 1.65;
  user-select: text;
}

.guide h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 24px;
}

.guide h3 {
  margin: 22px 0 6px;
  color: var(--ink);
  font-size: 17px;
}

.guide p,
.guide li {
  margin: 0 0 10px;
}

.guide ul,
.guide ol {
  padding-left: 22px;
}

.guide kbd {
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  background: transparent;
  font: inherit;
  font-size: 13px;
}

.guide h2:not(:first-child) {
  margin-top: 40px;
}

.guide a,
.more-games a {
  color: var(--accent-soft);
}

.more-games {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 64px;
  user-select: text;
}

.more-games h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.more-games ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.noscript-note {
  margin: 0;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--mark-ink);
  text-align: center;
}

@media (max-width: 640px) {
  .site-footer {
    flex-wrap: wrap;
    row-gap: 2px;
    column-gap: 12px;
  }

  .site-footer > [aria-hidden="true"] {
    display: none;
  }
}

.guide code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
}
