:root {
  color-scheme: dark;
  --bg: #030303;
  --surface: rgba(10, 10, 11, 0.84);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f0;
  --muted: #a6a6a0;
  --dim: #6d6d68;
  --signal: #e9ff70;
  --good: #67ff93;
  --almost: #f0c35a;
  --bad: #3d3d3a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(115deg, rgba(233, 255, 112, 0.08), transparent 28rem),
    linear-gradient(245deg, rgba(255, 255, 255, 0.06), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, #000, transparent 76%);
}

.game-page {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 0 64px;
}

.game-page::after {
  position: fixed;
  right: max(24px, 8vw);
  bottom: 52px;
  width: min(34vw, 420px);
  height: 1px;
  background: var(--line-strong);
  content: "";
}

.intro {
  display: grid;
  justify-items: center;
  padding: 32px 0 42px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 42px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 760;
}

.brand-mark {
  width: 17px;
  height: 17px;
  border: 2px solid var(--text);
  border-radius: 50%;
  box-shadow: inset 6px 0 0 var(--signal);
}

h1, h2 {
  margin: 0;
  font-weight: 880;
  line-height: 0.86;
  letter-spacing: 0;
}

h1 { font-size: clamp(64px, 14vw, 148px); }
h2 { font-size: clamp(42px, 8vw, 88px); }

.lede {
  max-width: 620px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.22;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 70%),
    var(--surface);
  padding: clamp(18px, 4vw, 34px);
}

.wordle-panel {
  display: grid;
  gap: 24px;
  justify-items: center;
}

.game-topline {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 18px;
  color: var(--signal);
  font-size: 12px;
  font-weight: 860;
  text-transform: uppercase;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  width: min(100%, 390px);
}

.row {
  display: grid;
  grid-template-columns: repeat(var(--word-length), 1fr);
  gap: 8px;
}

.tile {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: clamp(28px, 7vw, 46px);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  transform-style: preserve-3d;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tile.filled {
  border-color: rgba(245, 245, 240, 0.45);
  animation: pop 130ms ease-out;
}

.tile.flip {
  animation: flip 620ms ease forwards;
}

.tile.correct {
  border-color: rgba(103, 255, 147, 0.75);
  background: rgba(103, 255, 147, 0.72);
  color: #071008;
}

.tile.present {
  border-color: rgba(240, 195, 90, 0.85);
  background: rgba(240, 195, 90, 0.76);
  color: #17120a;
}

.tile.absent {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(85, 85, 80, 0.72);
  color: #f5f5f0;
}

.row.shake { animation: shake 420ms ease; }

.keyboard {
  display: grid;
  gap: 8px;
  width: min(100%, 560px);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  min-width: 0;
  height: 48px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  transition: transform 120ms ease, background 160ms ease;
}

.key:hover { transform: translateY(-1px); }
.key.wide { flex: 1.65; font-size: 12px; }
.key.correct { background: rgba(103, 255, 147, 0.72); color: #071008; }
.key.present { background: rgba(240, 195, 90, 0.76); color: #17120a; }
.key.absent { background: rgba(85, 85, 80, 0.72); }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  border: 1px solid rgba(233, 255, 112, 0.35);
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.94);
  box-shadow: 0 0 30px rgba(233, 255, 112, 0.12);
  color: var(--text);
  padding: 12px 18px;
  font-weight: 840;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal {
  width: min(540px, 100%);
  display: grid;
  gap: 16px;
  animation: modalIn 320ms ease both;
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.36;
}

.tools-kicker {
  margin: 0;
  color: var(--signal);
  font-size: 12px;
  font-weight: 860;
  text-transform: uppercase;
}

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

.result-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  padding: 14px;
}

.result-card strong {
  display: block;
  color: var(--signal);
  font-size: 28px;
  line-height: 1;
}

.result-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 42px;
  width: fit-content;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 0 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 780;
  white-space: nowrap;
}

.button-light {
  border: 1px solid #eff2d6;
  background: #f5f7e9;
  color: #11120e;
}

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

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

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 620px) {
  .game-page {
    width: min(100% - 24px, 760px);
    padding-bottom: 40px;
  }

  .game-topline {
    flex-direction: column;
    gap: 6px;
  }

  .tile {
    border-radius: 6px;
  }

  .key {
    height: 44px;
    padding: 0 4px;
    font-size: 12px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}
