  :root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #252836;
    --border: #3a3d4a;
    --text: #e8e6e3;
    --text-dim: #8b8d97;
    --correct: #22c55e;
    --correct-bg: #166534;
    --present: #eab308;
    --present-bg: #854d0e;
    --absent: #3a3d4a;
    --absent-bg: #1e2028;
    --accent: #60a5fa;
    --glow-correct: rgba(34, 197, 94, 0.3);
    --glow-present: rgba(234, 179, 8, 0.25);
    --tile-size: min(62px, calc((100vw - 60px) / 5));
    --key-h: 52px;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: 'Noto Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
  }

  body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(96,165,250,0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(34,197,94,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
  }

  header {
    position: relative; z-index: 1;
    width: 100%; max-width: 520px;
    padding: 16px 20px 12px;
    display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid var(--border);
    gap: 12px;
  }

  .logo {
    font-size: 26px; font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--correct), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .subtitle {
    font-size: 11px; color: var(--text-dim); letter-spacing: 1.5px;
    text-transform: uppercase;
  }

  .help-btn {
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 16px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
  }
  .help-btn:hover { background: var(--border); color: var(--text); }

  #game {
    position: relative; z-index: 1;
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 12px 10px;
    gap: 10px;
    width: 100%; max-width: 520px;
  }

  #board {
    display: grid;
    grid-template-rows: repeat(6, var(--tile-size));
    gap: 6px;
  }

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

  .tile {
    width: var(--tile-size); height: var(--tile-size);
    display: flex; align-items: center; justify-content: center;
    font-size: calc(var(--tile-size) * 0.44);
    font-weight: 800;
    text-transform: uppercase;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: transform 0.1s, border-color 0.15s;
    user-select: none;
  }

  .tile.filled {
    border-color: var(--text-dim);
    animation: pop 0.1s ease;
  }

  .tile.reveal {
    animation: flip 0.5s ease forwards;
  }

  .tile.correct {
    background: var(--correct-bg);
    border-color: var(--correct);
    box-shadow: 0 0 16px var(--glow-correct);
    color: #fff;
  }
  .tile.present {
    background: var(--present-bg);
    border-color: var(--present);
    box-shadow: 0 0 12px var(--glow-present);
    color: #fff;
  }
  .tile.absent {
    background: var(--absent-bg);
    border-color: var(--absent);
    color: var(--text-dim);
  }

  @keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
  }

  @keyframes flip {
    0% { transform: scaleY(1); }
    49% { transform: scaleY(0); }
    50% { transform: scaleY(0); }
    100% { transform: scaleY(1); }
  }

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

  .row.shake { animation: shake 0.4s ease; }

  @keyframes bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-8px); }
  }

  .tile.win-bounce {
    animation: bounce 0.6s ease;
  }

  #keyboard {
    position: relative; z-index: 1;
    width: 100%; max-width: 520px;
    padding: 0 4px 10px;
    display: flex; flex-direction: column;
    gap: 5px; align-items: center;
  }

  .kb-row {
    display: flex; gap: 4px; justify-content: center;
    width: 100%;
  }

  .key {
    height: var(--key-h);
    min-width: 28px;
    flex: 1;
    max-width: 42px;
    border: none;
    border-radius: 6px;
    background: var(--surface2);
    color: var(--text);
    font-family: 'Noto Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.1s, color 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-transform: uppercase;
  }

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

  .key.wide {
    min-width: 52px; max-width: 64px;
    font-size: 11px; letter-spacing: 0.5px;
  }

  .key.key-correct {
    background: var(--correct-bg); border: 1px solid var(--correct); color: #fff;
  }
  .key.key-present {
    background: var(--present-bg); border: 1px solid var(--present); color: #fff;
  }
  .key.key-absent {
    background: #1a1b22; color: #555;
  }

  /* Toast */
  #toast-container {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
    z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center;
  }

  .toast {
    background: var(--text); color: var(--bg);
    padding: 10px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 700;
    animation: fadeInOut 1.8s ease forwards;
    white-space: nowrap;
  }

  @keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    15% { opacity: 1; transform: translateY(0); }
    75% { opacity: 1; }
    100% { opacity: 0; }
  }

  /* Modal */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
  }
  .modal-overlay.open { opacity: 1; pointer-events: all; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 420px; width: 100%;
    padding: 28px 24px;
    transform: scale(0.9);
    transition: transform 0.25s;
  }
  .modal-overlay.open .modal { transform: scale(1); }

  .modal h2 {
    font-size: 20px; font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--correct), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .modal p {
    font-size: 14px; color: var(--text-dim);
    line-height: 1.7; margin-bottom: 12px;
  }

  .example-row {
    display: flex; gap: 5px; margin: 10px 0 6px;
  }

  .mini-tile {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--surface2);
    text-transform: uppercase;
  }

  .mini-tile.ex-correct { background: var(--correct-bg); border-color: var(--correct); color: #fff; }
  .mini-tile.ex-present { background: var(--present-bg); border-color: var(--present); color: #fff; }
  .mini-tile.ex-absent  { background: var(--absent-bg);  border-color: var(--absent);  color: var(--text-dim); }

  .modal .close-btn {
    margin-top: 16px; width: 100%; padding: 12px;
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 15px; font-weight: 700;
    cursor: pointer; transition: background 0.15s;
  }
  .modal .close-btn:hover { background: var(--border); }

  /* End modal */
  .end-modal h2 { margin-bottom: 8px; }
  .end-modal .answer-word {
    font-size: 28px; font-weight: 900; letter-spacing: 4px;
    color: var(--correct); margin: 8px 0 14px;
    text-transform: uppercase;
  }
  .end-modal .stats-row {
    display: flex; justify-content: center; gap: 20px; margin: 14px 0;
  }
  .stat-item {
    display: flex; flex-direction: column; align-items: center;
  }
  .stat-item .num {
    font-size: 28px; font-weight: 900; color: var(--text);
  }
  .stat-item .label {
    font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
  }
  .new-game-btn {
    margin-top: 14px; width: 100%; padding: 14px;
    background: linear-gradient(135deg, var(--correct-bg), #166534);
    border: 1px solid var(--correct); border-radius: 10px;
    color: #fff; font-size: 16px; font-weight: 800;
    cursor: pointer; transition: transform 0.15s, opacity 0.15s;
    letter-spacing: 1px;
  }
  .new-game-btn:hover { transform: scale(1.02); }
  .new-game-btn:active { transform: scale(0.98); }

  @media (max-width: 400px) {
    :root { --tile-size: calc((100vw - 52px) / 5); --key-h: 48px; }
    .key { font-size: 12px; min-width: 24px; }
    .key.wide { min-width: 42px; font-size: 10px; }
  }

.panel {
  width: 100%;
  max-width: 520px;
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  position: relative;
  z-index: 1;
}

.panel h3 {
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.kv {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.kv-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.kv-item .num {
  font-weight: 800;
  font-size: 20px;
}

.kv-item .lbl {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.list-item .row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.list-item .row2 {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.35;
}

.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.badge.won {
  border-color: var(--correct);
  color: var(--correct);
}

.badge.lost {
  border-color: var(--present);
  color: var(--present);
}

.badge.not_played {
  color: var(--text-dim);
}

.end-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.end-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.end-actions button:hover {
  background: var(--border);
}

#shareLinkBox {
  margin-top: 10px;
  word-break: break-all;
  color: var(--accent);
  font-size: 12px;
}

#dayUnavailable {
  display: none;
  width: 100%;
  max-width: 520px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
  color: var(--present);
  text-align: center;
}

.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(26, 29, 39, 0.98);
  backdrop-filter: blur(8px);
  padding: 14px 14px 12px;
  z-index: 260;
  display: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.install-banner.open {
  display: block;
  animation: install-banner-in 0.22s ease;
}

.install-banner-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.install-banner-text {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  padding-right: 20px;
}

.install-banner-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.install-banner-actions button {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--correct);
  background: var(--correct-bg);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.install-banner-actions button.secondary {
  border-color: var(--border);
  background: var(--surface2);
  color: var(--text);
}

.install-banner-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

@keyframes install-banner-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
