/* GIGGLE — daily 6-letter word puzzle. House palette: dark + gold + pink. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0a070e;
  --panel: #17111e;
  --text: #f0e8dc;
  --dim: rgba(240, 232, 220, 0.55);
  --pink: #ff6ec7;
  --gold: #d4a24c;
  --correct: #3f9d63;
  --present: #d4a24c;
  --absent: #2b2333;
  --tile-border: #3a3144;
  --key: #4a3f58;
}
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body {
  overscroll-behavior: none;
  /* Playful color wash so the dark theme feels lively, not austere. */
  background-image:
    radial-gradient(900px 480px at 8% -6%,  rgba(255,110,199,.14), transparent 60%),
    radial-gradient(820px 520px at 100% 4%, rgba(212,162,76,.13), transparent 58%),
    radial-gradient(900px 640px at 50% 116%, rgba(150,90,230,.16), transparent 62%);
  background-attachment: fixed;
}

:root { --tg-nav-height: 40px; }
#app {
  position: relative; z-index: 1;
  height: calc(100dvh - var(--tg-nav-height, 40px));
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 0 10px env(safe-area-inset-bottom);
}

/* ── Hostess backdrop ── */
#host-bg {
  position: fixed; inset: var(--tg-nav-height, 40px) 0 0 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
}
/* Warm aura behind the figure so she glows instead of fading into black. */
#host-bg::before {
  content: ""; position: absolute; bottom: -8%; left: 50%; transform: translateX(-50%);
  width: 90vw; max-width: 620px; height: 78vh;
  background: radial-gradient(circle at 50% 62%, rgba(255,110,199,.20), rgba(212,162,76,.12) 42%, transparent 70%);
  filter: blur(8px);
}
#host-bg img {
  position: relative;
  height: 82vh; max-width: none; opacity: 0.26; filter: saturate(1.18) contrast(1.04);
  -webkit-mask-image: linear-gradient(to bottom, transparent 4%, rgba(0,0,0,.55) 32%, #000 64%);
  mask-image: linear-gradient(to bottom, transparent 4%, rgba(0,0,0,.55) 32%, #000 64%);
  transition: opacity .4s ease;
}

/* ── Top bar ── */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px 8px;
  border-bottom: 1px solid rgba(212, 162, 76, 0.18);
}
.brand {
  margin: 0; font-size: 26px; letter-spacing: 0.14em; font-weight: 900;
  color: var(--gold); font-family: Georgia, serif;
}
.brand-pink { color: var(--pink); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: none; border: 1px solid rgba(255,255,255,0.16);
  color: var(--dim); font-size: 17px; font-weight: 700; cursor: pointer;
}
.icon-btn:hover { border-color: rgba(255,255,255,0.4); color: var(--text); }

/* ── Hostess strip ── */
#hostess {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px 10px;
  min-height: 44px;
}
.host-avatar {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  overflow: hidden; background: #1a1612;
  border: 1.5px solid rgba(212, 162, 76, 0.5);
  box-shadow: 0 0 12px rgba(212, 162, 76, 0.12);
}
.host-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.host-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.3; }
.host-name {
  font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold);
}
.host-line { font-size: 13px; color: rgba(240, 232, 220, 0.82); font-style: italic; }
#hostess.reacting .host-avatar { border-color: var(--pink); box-shadow: 0 0 16px rgba(255, 110, 199, 0.28); }
#hostess.reacting .host-line { color: var(--text); font-style: normal; }

/* ── Board ── */
#board {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center;
  padding: 12px 0;
}
.row { display: flex; gap: 6px; }
.row.shake { animation: shake 480ms ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); }
}
.tile {
  width: min(56px, 13vw); height: min(56px, 13vw);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--tile-border); border-radius: 8px;
  font-size: clamp(20px, 6vw, 28px); font-weight: 800; text-transform: uppercase;
  background: transparent; color: var(--text);
  transition: transform 80ms ease;
}
.tile.filled { border-color: #5d5070; animation: pop 90ms ease; }
@keyframes pop { 50% { transform: scale(1.08); } }
.tile.flip { animation: flip 480ms ease forwards; }
@keyframes flip {
  0%   { transform: rotateX(0); }
  49%  { transform: rotateX(90deg); }
  51%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
.tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.tile.present { background: var(--present); border-color: var(--present); color: #2a1c04; }
.tile.absent  { background: var(--absent);  border-color: var(--absent);  color: rgba(240,232,220,0.55); }
.tile.bounce { animation: bounce 600ms ease; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); } 35% { transform: translateY(-14px); } 65% { transform: translateY(4px); }
}

/* ── Keyboard ── */
#keyboard { padding: 6px 0 12px; user-select: none; }
.kb-row { display: flex; gap: 5px; justify-content: center; margin-bottom: 6px; }
.key {
  flex: 1; max-width: 42px; height: 52px;
  border: 0; border-radius: 7px;
  background: var(--key); color: var(--text);
  font-size: 14px; font-weight: 800; text-transform: uppercase;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.key.wide { max-width: 64px; flex: 1.5; font-size: 11.5px; }
.key:active { filter: brightness(1.25); }
.key.correct { background: var(--correct); }
.key.present { background: var(--present); color: #2a1c04; }
.key.absent  { background: #221b2b; color: rgba(240,232,220,0.35); }

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; top: calc(var(--tg-nav-height, 40px) + 60px); transform: translateX(-50%);
  z-index: 90; pointer-events: none;
  background: var(--text); color: #181020;
  border-radius: 10px; padding: 10px 18px;
  font-weight: 800; font-size: 14px;
  opacity: 0; transition: opacity 160ms ease;
}
#toast.show { opacity: 1; }

/* ── Modals ── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(5, 3, 8, 0.78); backdrop-filter: blur(3px);
  padding: 18px;
}
.modal.show { display: flex; }
.modal-card {
  position: relative;
  width: 100%; max-width: 380px; max-height: calc(100dvh - 60px); overflow-y: auto;
  background: var(--panel); border: 1px solid rgba(212, 162, 76, 0.35);
  border-radius: 20px; padding: 22px;
  animation: card-in 200ms ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: 0; color: var(--dim);
  font-size: 24px; cursor: pointer; line-height: 1; padding: 4px;
}
.modal-card h2 { margin: 0 0 10px; font-family: Georgia, serif; color: var(--gold); }
.modal-card h3 { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--dim); }
.modal-card p { font-size: 14.5px; line-height: 1.5; color: rgba(240,232,220,0.8); margin: 8px 0; }
.help-row { display: flex; gap: 4px; margin: 10px 0 2px; }
.tile.small { width: 34px; height: 34px; font-size: 16px; border-radius: 6px; }
.c-correct { color: var(--correct); } .c-present { color: var(--present); } .c-absent { color: #8f829e; }
.btn-play {
  display: block; width: 100%; margin-top: 16px;
  padding: 13px; border: 0; border-radius: 12px;
  background: var(--pink); color: #2a0a1e;
  font-size: 16px; font-weight: 800; cursor: pointer;
  transition: transform 120ms ease;
}
.btn-play:active { transform: scale(0.97); }

/* ── Stats ── */
.stats-answer { font-size: 15px; }
.stats-answer b { color: var(--pink); letter-spacing: 0.08em; }
.stats-grid { display: flex; gap: 8px; margin: 12px 0 4px; }
.stat { flex: 1; text-align: center; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 10px 4px; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#dist { display: flex; flex-direction: column; gap: 4px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist-row .n { width: 12px; color: var(--dim); }
.dist-bar {
  min-width: 22px; padding: 2px 8px; border-radius: 5px;
  background: var(--absent); color: var(--text);
  font-weight: 800; text-align: right; font-size: 13px;
}
.dist-bar.hit { background: var(--correct); color: #fff; }
.stats-footer {
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 16px; padding-top: 14px;
}
.next { flex: 1; }
.next span { display: block; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.next b { font-size: 22px; font-variant-numeric: tabular-nums; }
#btn-share {
  flex: 1; padding: 13px; border: 0; border-radius: 12px;
  background: var(--pink); color: #2a0a1e;
  font-size: 16px; font-weight: 800; cursor: pointer;
  transition: transform 120ms ease;
}
#btn-share:active { transform: scale(0.97); }

/* ── Achievements (local) ─────────────────────────────── */
.ach-head { display: flex; align-items: center; justify-content: space-between; }
.ach-count { font-size: 13px; font-weight: 700; color: var(--gold); background: rgba(212,162,76,0.14); padding: 2px 9px; border-radius: 999px; }
#achievements { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
@media (max-width: 380px) { #achievements { grid-template-columns: 1fr; } }
.ach {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(212,162,76,0.3);
  border-radius: 11px; min-width: 0;
}
.ach.locked { opacity: 0.42; border-color: rgba(255,255,255,0.08); filter: grayscale(0.7); }
.ach-ico { font-size: 20px; line-height: 1; flex: 0 0 auto; }
.ach-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ach-txt b { font-size: 12.5px; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ach-txt small { font-size: 10.5px; color: var(--muted, #b59ec5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
