/* ============ The Big Word — liquid glass, dark only ============ */
:root {
  color-scheme: dark;
  --bg: #101012;
  --font-serif: ui-serif, "New York", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --text: rgba(255, 255, 255, 0.92);
  --text-dim: rgba(255, 255, 255, 0.55);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.22);
  --green: #34d399;
  --yellow: #fbbf24;
  --gray-tile: rgba(255, 255, 255, 0.04);
  --radius: 18px;
  --board-w: min(94vw, 540px);
  --board-pad: 12px;
  --tile-gap: 6px;
  /* explicit tile size: flexible tracks + aspect-ratio trigger intrinsic-sizing
     bugs in both Blink and WebKit, so tiles are sized by hand */
  --tile: calc((var(--board-w) - 2 * var(--board-pad) - 9 * var(--tile-gap)) / 10);
}

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

html { height: 100%; }

body {
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  /* rapid taps (e.g. hammering backspace) must not trigger double-tap zoom;
     pinch-zoom stays available for accessibility */
  touch-action: manipulation;
}

/* ---------- starry night sky ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(120, 130, 160, 0.09), transparent 60%),
    radial-gradient(ellipse at 85% 100%, rgba(90, 110, 130, 0.06), transparent 55%),
    var(--bg);
}
/* Each layer tiles a handful of gradient "stars" at a different scale,
   so the repeats never line up and the field reads as random. */
.stars {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
}
.stars-a {
  background-image:
    radial-gradient(1px 1px at 22px 34px, rgba(255, 255, 255, 0.9), transparent 100%),
    radial-gradient(1px 1px at 118px 89px, rgba(255, 255, 255, 0.7), transparent 100%),
    radial-gradient(1px 1px at 71px 152px, rgba(255, 255, 255, 0.8), transparent 100%),
    radial-gradient(1px 1px at 163px 21px, rgba(255, 255, 255, 0.6), transparent 100%),
    radial-gradient(1px 1px at 191px 133px, rgba(255, 255, 255, 0.75), transparent 100%);
  background-size: 213px 213px;
  opacity: 0.7;
}
.stars-b {
  background-image:
    radial-gradient(1.5px 1.5px at 47px 112px, rgba(255, 255, 255, 0.95), transparent 100%),
    radial-gradient(1px 1px at 205px 46px, rgba(220, 230, 255, 0.7), transparent 100%),
    radial-gradient(1px 1px at 132px 219px, rgba(255, 255, 255, 0.65), transparent 100%),
    radial-gradient(1.5px 1.5px at 259px 167px, rgba(255, 245, 225, 0.8), transparent 100%);
  background-size: 307px 307px;
  opacity: 0.8;
  animation: twinkle 5.5s ease-in-out infinite alternate;
}
.stars-c {
  background-image:
    radial-gradient(2px 2px at 88px 58px, rgba(255, 255, 255, 0.9), transparent 100%),
    radial-gradient(1.5px 1.5px at 301px 274px, rgba(210, 225, 255, 0.85), transparent 100%),
    radial-gradient(2px 2px at 199px 339px, rgba(255, 250, 235, 0.75), transparent 100%);
  background-size: 401px 401px;
  animation: twinkle 8s ease-in-out 2s infinite alternate;
}
@keyframes twinkle {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* ---------- glass primitives ---------- */
.glass, .glass-panel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 12px 40px rgba(0, 0, 0, 0.35);
}

/* ---------- top bar ---------- */
.topbar {
  width: var(--board-w);
  margin-top: max(14px, env(safe-area-inset-top));
  padding: 10px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.title {
  font-family: var(--font-serif);
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 600;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  white-space: nowrap;
  color: #ffffff;
}
.title-big {
  font-weight: 800;
  color: #ffffff;
}
.icon-btn {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- layout ---------- */
.game {
  width: var(--board-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 16px 0 max(16px, env(safe-area-inset-bottom));
  flex: 1;
  justify-content: center;
}

/* ---------- bonus round pill ---------- */
.mode-pill {
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fde68a;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- board ---------- */
.board {
  width: 100%;
  padding: var(--board-pad);
  border-radius: var(--radius);
  display: grid;
  gap: var(--tile-gap);
}
.row {
  display: grid;
  grid-template-columns: repeat(10, var(--tile));
  gap: var(--tile-gap);
  justify-content: center;
}
.tile {
  width: var(--tile);
  height: var(--tile);
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--gray-tile);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: clamp(14px, 4.2vw, 27px);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.tile.filled {
  border-color: var(--glass-highlight);
  background: var(--glass-strong);
  animation: pop 0.12s ease;
}
@keyframes pop { 50% { transform: scale(1.08); } }

.tile.reveal { animation: flip 0.5s ease both; }
@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
.tile.correct {
  background: rgba(52, 211, 153, 0.28);
  border-color: rgba(52, 211, 153, 0.38);
  color: #e4fcf2;
}
.tile.present {
  background: rgba(251, 191, 36, 0.24);
  border-color: rgba(251, 191, 36, 0.36);
  color: #fdf4dd;
}
.tile.absent {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.35);
}
.tile.unused {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.04);
}
.tile.win-bounce { animation: bounce 0.6s ease both; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-42%); }
  70% { transform: translateY(8%); }
}
.row.shake { animation: shake 0.4s ease; }
@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------- keyboard ---------- */
.keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  user-select: none;
  -webkit-user-select: none;
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.key {
  flex: 1;
  max-width: 46px;
  height: 52px;
  touch-action: manipulation;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
}
.key:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.2); }
.key.wide { flex: 1.6; max-width: 76px; font-size: 12px; }
.key.correct {
  background: rgba(52, 211, 153, 0.3);
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: none;
  color: #e4fcf2;
}
.key.present {
  background: rgba(251, 191, 36, 0.26);
  border-color: rgba(251, 191, 36, 0.38);
  box-shadow: none;
  color: #fdf4dd;
}
.key.absent {
  background: rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.3);
}

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(20, 20, 34, 0.75);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  animation: toast-in 0.25s ease both;
}
.toast.out { animation: toast-out 0.3s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(0.95); } }

/* ---------- modals ---------- */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 5, 12, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
.modal-scrim.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.modal {
  position: relative;
  width: min(92vw, 440px);
  max-height: 84vh;
  overflow-y: auto;
  border-radius: 24px;
  padding: 28px 26px 26px;
  background: rgba(24, 24, 40, 0.62);
  animation: modal-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
.modal h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.modal h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 20px 0 10px;
}
.modal p { font-size: 14.5px; line-height: 1.55; color: var(--text-dim); margin-bottom: 12px; }
.modal p strong { color: var(--text); }
.modal-close { position: absolute; top: 16px; right: 16px; font-size: 20px; font-weight: 400; }
.rule-highlight {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.22);
}
.c-green { color: var(--green); }
.c-yellow { color: var(--yellow); }
.c-gray { color: rgba(255, 255, 255, 0.45); }
.fineprint { font-size: 12.5px; margin-top: 14px; margin-bottom: 0; }

.example-row {
  display: flex;
  gap: 4px;
  margin: 14px 0 10px;
}
.example-row .tile {
  width: 30px;
  height: 30px;
  font-size: 14px;
  flex: none;
}

/* ---------- stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.stat {
  text-align: center;
  padding: 12px 4px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.stat-num { font-family: var(--font-serif); font-size: 26px; font-weight: 700; }
.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-top: 2px;
}
.dist { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist-n { width: 12px; color: var(--text-dim); font-weight: 600; }
.dist-bar {
  min-width: 24px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  font-weight: 700;
  font-size: 12px;
  transition: width 0.4s ease;
}
.dist-bar.hit {
  background: rgba(52, 211, 153, 0.34);
}
.stats-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.countdown-time {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.btn-share {
  padding: 13px 30px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.26);
  color: #e4fcf2;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn-share:hover { background: rgba(52, 211, 153, 0.34); }
.btn-share:active { transform: scale(0.95); }

.reveal {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.btn-bonus {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.38);
  background: rgba(251, 191, 36, 0.22);
  color: #fdf4dd;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn-bonus:hover { background: rgba(251, 191, 36, 0.3); }
.btn-bonus:active { transform: scale(0.97); }

.bonus-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.bonus-actions .btn-share { width: 100%; }
.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.btn-secondary:active { transform: scale(0.97); }

.reveal strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--text);
  margin-top: 4px;
  text-transform: uppercase;
}
.hidden { display: none; }

/* ---------- footer ---------- */
.site-footer {
  width: 100%;
  padding: 4px 0 max(14px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.32);
}

/* ---------- ad gate ---------- */
.ad-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 8, 12, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.25s ease;
}
.ad-gate.hidden { display: none; }
.ad-panel {
  width: min(92vw, 400px);
  border-radius: 24px;
  padding: 20px;
  background: rgba(24, 24, 34, 0.7);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modal-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.ad-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-align: center;
}
.ad-box {
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.house-ad {
  text-align: center;
  padding: 16px;
}
.house-ad-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  margin-bottom: 10px;
}
.house-ad p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
.ad-play:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

/* ---------- small screens ---------- */
@media (max-width: 400px) {
  :root { --board-pad: 8px; --tile-gap: 4px; }
  .tile { border-radius: 7px; }
  .key { height: 48px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .stars { animation: none; }
  .tile.reveal, .tile.win-bounce, .row.shake { animation-duration: 0.01s; }
}
