﻿:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #1c1a17;
  --muted: #5c564c;
  --panel: #fffdf8;
  --line: #d9d1c3;
  --focus: #0b5cab;
  --correct: #0f6b3c;
  --correct-ink: #ffffff;
  --present: #8a6410;
  --present-ink: #2c2208;
  --absent: #5e6570;
  --absent-ink: #ffffff;
  --tile: clamp(2.15rem, 12vw, 3.5rem);
  --guess: #0e8f86;
  --extra: #5c45a6;
  --extra-used: #3d2f78;
  --extra-remain: #d5cef2;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 1.05rem;
  line-height: 1.45;
}

.game {
  width: min(40rem, calc(100% - 2rem));
  margin: 0 auto;
  flex: 1;
  padding: 1.5rem 0 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

h1,
h1 a {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
}

.logo {
  display: block;
  width: min(40rem, 100%);
  height: auto;
}

.logo-dark {
  display: none;
}

html.dark .logo-light {
  display: none;
}

html.dark .logo-dark {
  display: block;
}

.how-to-line {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.length-label {
  margin: 0.35rem 0 0;
  width: 100%;
  font-size: 0.95rem;
  color: var(--muted);
}

.length-name {
  position: relative;
  display: inline-block;
}

.length-name .points {
  position: absolute;
  left: calc(100% + 0.45rem);
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  color: var(--correct);
  font-weight: 750;
  white-space: nowrap;
}

.extra-buy {
  flex: 0 0 100%;
  display: flex;
  justify-content: safe center;
  gap: 0.45rem;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.15rem 0.15rem 0.35rem;
}

button.extra-choice {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  border: 2px solid var(--extra);
  border-radius: 0.5rem;
  background: var(--extra-remain);
  color: #2a2148;
  font-weight: 750;
}

button.extra-choice.selected {
  background: var(--extra-used);
  border-color: var(--extra-used);
  color: #fff;
}

#buy-guess {
  background: var(--extra);
  border-color: var(--extra);
  color: #fff;
  animation: buy-wait 1.8s ease-in-out infinite;
}

@keyframes buy-wait {
  0%, 100% {
    background-color: var(--extra-used);
    border-color: var(--extra-used);
    color: #fff;
  }
  50% {
    background-color: var(--extra-remain);
    border-color: var(--extra);
    color: #2a2148;
  }
}

#end-game {
  background: #c73b4a;
  border-color: #9a2432;
  color: #fff;
}

.copyright {
  margin: 0;
  padding: 0 1rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.copyright p {
  margin: 0.2rem 0;
}

.legal-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  font-weight: 650;
}

.legal-links a {
  color: var(--guess);
  margin: 0 0.2rem;
  text-decoration: none;
}

.options-gear {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.3rem;
  border: none;
  background: transparent;
  color: var(--guess);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.options-gear svg {
  width: 1.45rem;
  height: 1.45rem;
}

.options-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.options-form fieldset {
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.options-form legend {
  padding: 0 0.35rem;
  font-weight: 750;
}

.options-form label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}

.options-form label:has(input:disabled) {
  color: var(--muted);
  cursor: not-allowed;
}

.options-note {
  margin: -0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.game-timer {
  position: fixed;
  top: 0.55rem;
  left: 50%;
  z-index: 5;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.2rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
}

.guide article + .page-actions {
  margin-top: 1.5rem;
}

a.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  border: 2px solid var(--guess);
  border-radius: 0.5rem;
  background: var(--guess);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}

a.action-button.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: #243044;
}

.guide article a {
  color: var(--guess);
}

.guide {
  width: min(46rem, calc(100% - 2rem));
  margin: 0 auto;
  flex: 1;
  padding: 1.5rem 0 2.5rem;
  text-align: left;
}

.guide h1 {
  margin-bottom: 0.75rem;
}

.guide-nav {
  margin: 0 0 1.5rem;
  text-align: center;
}

.guide article + .guide-nav {
  margin-top: 1.5rem;
}

.play-link,
.full-instructions {
  color: var(--guess);
  font-weight: 750;
}

.guide article > h2 {
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--guess);
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  color: #16352c;
}

.guide article > h2:first-child {
  margin-top: 0;
}

.guide h3 {
  margin: 1.25rem 0 0.35rem;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.25rem;
  color: #0e8f86;
}

.guide p,
.guide li {
  color: var(--ink);
}

.guide p {
  margin: 0.75rem 0;
}

.clues {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.clues li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.swatch {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--tile);
  height: var(--tile);
  min-height: 0;
  aspect-ratio: 1;
  flex: 0 0 auto;
  padding: 0.12rem;
  border: none;
  border-radius: 0.9rem;
  color: #fff;
  box-shadow:
    inset 0 3px 2px rgba(255, 255, 255, 0.5),
    inset 0 -8px 10px rgba(0, 0, 0, 0.2),
    0 5px 0 rgba(70, 48, 28, 0.16),
    0 9px 12px rgba(48, 32, 16, 0.16);
}

.swatch-letter {
  font-size: clamp(1.15rem, 4vw, 1.6rem);
  font-weight: 750;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 1px rgba(0, 0, 0, 0.28);
}

.swatch-state,
.tile-state {
  margin-top: 0.12rem;
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.swatch.correct {
  background-color: #148a45;
  background-image: linear-gradient(180deg, #79e2a8 0%, #1f9a52 46%, #0c5a30 100%);
  color: var(--correct-ink);
}

.swatch.present {
  background-color: #c49712;
  background-image: linear-gradient(180deg, #f6e08a 0%, #e0b422 46%, #8a6410 100%);
  color: var(--present-ink);
}

.swatch.absent {
  background-color: #7d8692;
  background-image: linear-gradient(180deg, #d5dbe2 0%, #8b949e 48%, #4e5660 100%);
  color: var(--absent-ink);
}

.value-chart {
  display: block;
  width: 100%;
  height: auto;
  margin: 1.25rem 0 0.5rem;
}

.costs {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  background: var(--panel);
}

.costs caption {
  margin-bottom: 0.45rem;
  text-align: left;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #16352c;
}

.costs th,
.costs td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.costs th {
  background: #16352c;
  color: #fff;
}

.costs td:last-child,
.costs th:last-child {
  text-align: right;
}

dialog {
  border: 2px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.25rem 1.4rem;
  max-width: 36rem;
  width: calc(100% - 2rem);
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

dialog::backdrop {
  background: rgba(28, 26, 23, 0.45);
}

dialog h2 {
  margin: 0 0 0.75rem;
  text-align: center;
}

dialog p {
  margin: 0 0 0.75rem;
}

dialog button {
  display: block;
  margin: 0.5rem auto 0;
}

.score-line,
.actions,
.offer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem 1rem;
}

.offer {
  flex-direction: column;
}

select,
button,
.tile-input {
  font: inherit;
}

select {
  min-height: 2.75rem;
  min-width: 10rem;
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--ink);
}

.status,
.score-line,
.result {
  margin: 0;
}

.status.metered {
  width: min(22rem, 100%);
  font-size: 1rem;
}

.guess-meter {
  position: relative;
  display: block;
  width: 100%;
  height: 2.6rem;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(40, 30, 16, 0.16), 0 2px 0 rgba(255, 255, 255, 0.7);
}

.guess-meter-track {
  display: flex;
  width: 100%;
  height: 100%;
  background: #efe8dc;
}

.guess-meter-seg {
  height: 100%;
  min-width: 0;
}

.guess-meter-seg.used-normal {
  background: #0a6e66;
}

.guess-meter-seg.remain-normal {
  background: #b7e6e1;
}

.guess-meter-seg.used-extra {
  background: var(--extra-used);
}

.guess-meter-seg.remain-extra {
  background: var(--extra-remain);
}

.guess-meter-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.guess-meter-caption {
  padding: 0.12rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  color: #1a1428;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(28, 22, 40, 0.28);
}

.status.game-over {
  font-size: 3.1em;
  line-height: 1.05;
  text-shadow: 2px 2px 0 #ff0000, 4px 4px 0 #0000ff;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.score-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
}

.score-line {
  font-size: 1.85rem;
  font-weight: 750;
}

.to-beat {
  margin: 0;
  color: #800000;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.15;
}

.score-line.topped {
  color: #b8860b;
  text-shadow: 0 0 0.45rem rgba(255, 210, 40, 0.9);
}

.score-line.topped .flap {
  animation: score-glow 1.35s ease-in-out infinite;
}

@keyframes score-glow {
  0%,
  100% {
    box-shadow:
      0 0 0.28rem rgba(255, 210, 40, 0.75),
      0 0.12em 0 #0c121a,
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow:
      0 0 0.9rem 0.18rem rgba(255, 220, 60, 0.95),
      0 0.12em 0 #0c121a,
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

#share-result.topped {
  animation: share-glow 1.35s ease-in-out infinite;
}

@keyframes share-glow {
  0%,
  100% { box-shadow: 0 0 0.55rem 0.12rem rgba(255, 196, 20, 0.95); }
  50% { box-shadow: 0 0 1.35rem 0.4rem rgba(255, 220, 70, 1); }
}

.flip-score {
  display: inline-flex;
  gap: 0.16rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.flap {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 0.92em;
  height: 1.35em;
  padding: 0 0.08em;
  border-radius: 0.16em;
  background: linear-gradient(#314056 0 49.5%, #1b2636 50.5% 100%);
  color: #f6f0e4;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: 0 0.12em 0 #0c121a, inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.flap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 1px);
  height: 2px;
  background: #0b1016;
  z-index: 1;
}

.flap.turning .flap-num {
  animation: flap-drop 0.42s ease-out;
  transform-origin: center top;
}

@keyframes flap-drop {
  0% { transform: rotateX(-88deg); }
  100% { transform: rotateX(0); }
}

.board {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.row,
.guess-form {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
}

.guess-form {
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.row {
  align-items: center;
}

.letters {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.multiplier {
  position: absolute;
  left: calc(100% + 0.55rem);
  top: 50%;
  transform: translateY(-50%);
  color: var(--guess);
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.tile-slot {
  font: inherit;
  cursor: text;
  appearance: none;
}

.guess-capture {
  position: absolute;
  z-index: 2;
  margin: 0;
}

.cost {
  position: absolute;
  left: calc(100% + 0.55rem);
  top: 50%;
  transform: translateY(-50%);
  color: #c62828;
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.tile {
  position: relative;
  cursor: help;
}

.tile:hover::after {
  content: attr(data-worth);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.3rem);
  transform: translateX(-50%);
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  background: #243044;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}

.tile,
.tile-input,
.tile-slot {
  width: var(--tile);
  min-height: 2.75rem;
  margin: 0;
  padding: 0.2rem 0.1rem 0.3rem;
  border: 2px solid var(--line);
  border-radius: 0.45rem;
  background: var(--panel);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tile-input {
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(1.15rem, 4vw, 1.6rem);
  font-weight: 750;
}

.tile-letter {
  font-size: clamp(1.15rem, 4vw, 1.6rem);
  font-weight: 750;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 1px rgba(0, 0, 0, 0.28);
}

.tile {
  width: var(--tile);
  height: var(--tile);
  min-height: 0;
  aspect-ratio: 1;
  padding: 0.12rem;
  border: none;
  border-radius: 0.9rem;
  box-shadow:
    inset 0 3px 2px rgba(255, 255, 255, 0.5),
    inset 0 -8px 10px rgba(0, 0, 0, 0.2),
    0 5px 0 rgba(70, 48, 28, 0.16),
    0 9px 12px rgba(48, 32, 16, 0.16);
}

.tile.correct {
  background-color: #148a45;
  background-image: linear-gradient(180deg, #79e2a8 0%, #1f9a52 46%, #0c5a30 100%);
  color: var(--correct-ink);
}

.tile.present {
  background-color: #c49712;
  background-image: linear-gradient(180deg, #f6e08a 0%, #e0b422 46%, #8a6410 100%);
  color: var(--present-ink);
}

.tile.absent {
  background-color: #7d8692;
  background-image: linear-gradient(180deg, #d5dbe2 0%, #8b949e 48%, #4e5660 100%);
  color: var(--absent-ink);
}

.tile.hint {
  z-index: 1;
  animation: hint-throb 1.15s ease-in-out infinite;
}

@keyframes hint-throb {
  0%,
  100% {
    box-shadow:
      inset 0 3px 2px rgba(255, 255, 255, 0.5),
      inset 0 -8px 10px rgba(0, 0, 0, 0.2),
      0 5px 0 rgba(70, 48, 28, 0.16),
      0 9px 12px rgba(48, 32, 16, 0.16),
      0 0 0.15rem rgba(255, 214, 0, 0.35);
  }
  50% {
    box-shadow:
      inset 0 3px 2px rgba(255, 255, 255, 0.5),
      inset 0 -8px 10px rgba(0, 0, 0, 0.2),
      0 5px 0 rgba(70, 48, 28, 0.16),
      0 0 0.25rem 0.45rem rgba(255, 214, 0, 0.95),
      0 0 1.35rem 0.15rem rgba(255, 190, 0, 0.8);
  }
}

button {
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  background: #243044;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: #243044;
}

#submit-guess {
  min-height: 3.65rem;
  padding: 0.85rem 1.85rem;
  font-size: 1.32rem;
  background: var(--guess);
  border-color: var(--guess);
  color: #fff;
}

#submit-guess.extra-guess {
  background: var(--extra);
  border-color: var(--extra);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions .result {
  flex-basis: 100%;
  font-size: 1.25rem;
  font-weight: 500;
}

.result .missed-word {
  color: var(--correct);
  font-weight: 800;
}

.result.winner {
  font-size: clamp(2rem, 8vw, 3.1rem);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.result.winner span {
  display: inline-block;
  animation: prism 1.8s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * 0.14s);
}

@keyframes prism {
  0% { color: hsl(0, 92%, 52%); }
  16% { color: hsl(28, 96%, 50%); }
  33% { color: hsl(52, 95%, 46%); }
  50% { color: hsl(145, 75%, 38%); }
  66% { color: hsl(200, 90%, 46%); }
  83% { color: hsl(265, 85%, 58%); }
  100% { color: hsl(325, 90%, 54%); }
}

.notice {
  flex: 0 0 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (min-width: 40rem) {
  :root {
    --tile: clamp(2.75rem, 8vw, 3.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
    transition: none;
  }

  .result.winner span,
  .status.game-over,
  #buy-guess {
    animation: none;
  }

  .result.winner span:nth-child(1) { color: hsl(0, 92%, 52%); }
  .result.winner span:nth-child(2) { color: hsl(28, 96%, 50%); }
  .result.winner span:nth-child(3) { color: hsl(52, 95%, 46%); }
  .result.winner span:nth-child(4) { color: hsl(145, 75%, 38%); }
  .result.winner span:nth-child(5) { color: hsl(200, 90%, 46%); }
  .result.winner span:nth-child(6) { color: hsl(265, 85%, 58%); }
  .result.winner span:nth-child(7) { color: hsl(325, 90%, 54%); }

  .tile.hint {
    animation: none;
    box-shadow:
      inset 0 3px 2px rgba(255, 255, 255, 0.5),
      inset 0 -8px 10px rgba(0, 0, 0, 0.2),
      0 5px 0 rgba(70, 48, 28, 0.16),
      0 9px 12px rgba(48, 32, 16, 0.16),
      0 0 0.55rem 0.2rem rgba(255, 214, 0, 0.9);
  }

  .flap.turning .flap-num,
  .score-line.topped .flap,
  #share-result.topped {
    animation: none;
  }

  .score-line.topped .flap {
    box-shadow:
      0 0 0.55rem rgba(255, 210, 40, 0.95),
      0 0.12em 0 #0c121a,
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }

  #share-result.topped {
    box-shadow: 0 0 0.85rem 0.15rem rgba(255, 196, 20, 0.95);
  }
}

html.dark {
  color-scheme: dark;
  --bg: #141210;
  --ink: #f6f1e8;
  --muted: #c8bfb2;
  --panel: #241f1a;
  --line: #5c5348;
  --focus: #8ec0ff;
}

html.dark .guide article > h2,
html.dark .guide h3,
html.dark .costs caption {
  color: #d7efe4;
}

html.dark a.action-button.secondary,
html.dark button.secondary {
  border-color: #d7cfc3;
}

html.dark .to-beat {
  color: #c45c6a;
}
