:root {
  color-scheme: light;
  --ink: #111111;
  --muted: #6f6f6a;
  --line: #deded9;
  --soft: #f1f1ed;
  --key: #e6e6e1;
  --green: #238636;
  --red: #c93434;
  --tile: clamp(24px, calc((100vw - 104px) / 8), 32px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  background: #ffffff;
}

body {
  min-width: 300px;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.game {
  display: flex;
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.letter-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
}

.known-table {
  border-color: #1b702d;
  background: var(--green);
  color: #ffffff;
}

.known-table .hint-heading,
.known-table .known-heading {
  border-bottom-color: rgba(255, 255, 255, 0.24);
}

.known-table .hint-heading > span,
.known-table .known-heading > span {
  color: rgba(255, 255, 255, 0.78);
}

.known-table .word-row {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.18);
}

.known-table .letter-tile.is-unknown {
  color: #a9cfb2;
}

.hint-heading {
  padding: 17px 15px 14px;
  border-bottom: 1px solid #ecece8;
}

.hint-heading > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint-heading h1 {
  margin: 0;
  font-size: clamp(1.35rem, 6vw, 1.75rem);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.known-heading,
.table-heading {
  display: flex;
  min-height: 48px;
  padding: 11px 15px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #ecece8;
}

.known-heading h2,
.table-heading h1,
.table-heading h2 {
  margin: 0;
}

.known-heading h2,
.table-heading h1,
.table-heading h2 {
  font-size: 0.92rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.known-heading > span,
.table-heading > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

#guessStatus.is-win {
  color: var(--green);
  font-weight: 850;
}

#guessStatus.is-wrong {
  color: var(--red);
  font-weight: 850;
}

.guess-table {
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.guess-table.is-wrong-feedback {
  border-color: var(--red);
  background: #fff5f5;
  box-shadow: 0 0 0 2px rgba(201, 52, 52, 0.18);
  animation: guess-shake 320ms ease;
}

.guess-table.is-wrong-feedback .table-heading,
.guess-table.is-wrong-feedback .word-row {
  border-color: #efb9b9;
  background: #ffeded;
}

.letter-board {
  display: flex;
  min-height: 76px;
  padding: 14px 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.word-row {
  display: flex;
  padding: 4px;
  gap: 3px;
  border: 1px solid #e1e1dc;
  border-radius: 10px;
  background: var(--soft);
}

.letter-tile,
.guess-tile {
  display: grid;
  width: var(--tile);
  height: calc(var(--tile) * 1.16);
  min-height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(0.9rem, 4.5vw, 1.15rem);
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  text-transform: uppercase;
}

.letter-tile.is-unknown {
  color: #c3c3bd;
  font-size: 0.8rem;
}

.letter-tile.is-new {
  animation: flip 280ms ease;
}

.guess-tile {
  cursor: pointer;
}

.guess-tile.is-given {
  background: #ecece7;
  color: #565651;
  cursor: default;
  box-shadow: none;
}

.guess-tile.is-active {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.guess-tile.is-correct {
  background: var(--green);
  color: #ffffff;
  box-shadow: none;
}

.guess-table.is-correct-feedback {
  border-color: var(--green);
  animation: correct-table 980ms ease both;
}

.guess-table.is-correct-feedback .guess-tile.is-correct {
  transform-origin: center;
  animation: correct-reveal 520ms cubic-bezier(0.2, 0.9, 0.25, 1.25) both;
  animation-delay: calc(var(--tile-index) * 42ms);
}

.reveal-button {
  display: inline-flex;
  min-height: 34px;
  margin: 0 auto;
  padding: 0 12px;
  align-items: center;
  gap: 7px;
  border: 1px solid #bdbdb7;
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.reveal-button small {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.reveal-button:active {
  background: var(--soft);
  transform: translateY(1px);
}

.reveal-button:disabled {
  color: #a4a49e;
  cursor: default;
}

.keypad {
  display: grid;
  gap: 6px;
  padding-top: 2px;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
}

.middle-row {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  padding: 0 4.7%;
}

.last-row {
  grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(48px, 1.55fr) minmax(52px, 1.7fr);
  gap: 4px;
}

.key-row button {
  height: 44px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--key);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.key-row button:active {
  background: #cfcfca;
  transform: translateY(1px);
}

.key-row button:disabled {
  color: #a4a49e;
  cursor: default;
}

.key-row .delete-key {
  background: #222222;
  color: #ffffff;
  font-size: 0.68rem;
}

.key-row .reset-key {
  border: 1px solid #c5c5bf;
  background: #ffffff;
  font-size: 0.66rem;
}

.score-chart {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
}

.score-chart[hidden] {
  display: none;
}

.score-heading {
  display: flex;
  margin-bottom: 12px;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.score-heading h2,
.score-heading strong {
  margin: 0;
  font-size: 0.9rem;
}

.score-heading strong {
  color: var(--green);
}

.score-bars {
  display: grid;
  gap: 5px;
}

.score-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 6px;
}

.score-row > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: right;
}

.score-track {
  height: 22px;
}

.score-bar {
  display: flex;
  height: 100%;
  min-width: 0;
  padding-right: 6px;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  border-radius: 4px;
  background: var(--green);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 850;
}

.score-chart p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.account-link {
  align-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes flip {
  0% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

@keyframes guess-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

@keyframes correct-reveal {
  0% {
    transform: rotateX(90deg) scale(0.82);
    background: #ffffff;
    color: transparent;
  }
  58% {
    transform: rotateX(-10deg) scale(1.1);
    background: #2ca849;
    color: #ffffff;
  }
  100% {
    transform: rotateX(0) scale(1);
    background: var(--green);
    color: #ffffff;
  }
}

@keyframes correct-table {
  0%, 100% { box-shadow: 0 0 0 rgba(35, 134, 54, 0); }
  45% { box-shadow: 0 0 0 5px rgba(35, 134, 54, 0.2); }
}

@media (max-height: 660px) {
  .game {
    justify-content: flex-start;
    gap: 10px;
    padding-top: 12px;
  }

  .letter-board {
    min-height: 66px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .key-row button {
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}
