:root {
  --bg: #0b0b14;
  --bg-elevated: #14141f;
  --card: #1b1b29;
  --border: #2b2b3d;
  --text: #f2f1f7;
  --text-dim: #9c9ab0;
  --accent: #ff4d8d;
  --accent-2: #7c5cff;
  --hit: #2fbf71;
  --close: #e8b923;
  --miss: #33323f;
  --radius: 14px;
  --max-width: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
}

.page {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

a { color: var(--accent); text-decoration: none; }

/* ---- header ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rank-pill {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---- cards / hub grid ---- */
.hero {
  text-align: center;
  padding: 12px 0 4px;
}

.hero h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
}

.hero p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0;
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.game-card:active { transform: scale(0.97); }

.game-card .emoji { font-size: 1.8rem; }
.game-card h3 { margin: 0; font-size: 1.02rem; }
.game-card p { margin: 0; color: var(--text-dim); font-size: 0.78rem; line-height: 1.3; }
.game-card .streak-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 600;
}

/* ---- ad slots ---- */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-align: center;
  padding: 14px;
  background: var(--bg-elevated);
}

/* ---- game screens ---- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link { font-size: 0.85rem; color: var(--text-dim); }

.tries-left {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.guess-box { position: relative; }

.guess-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
}

.guess-input:focus { outline: 2px solid var(--accent-2); }

.autocomplete-box {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-box.open { display: block; }

.autocomplete-item {
  padding: 10px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}

.autocomplete-item:hover { background: var(--bg-elevated); }

.submit-btn, .primary-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.submit-btn:active:not(:disabled), .primary-btn:active { transform: scale(0.97); }

.secondary-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.secondary-btn:active { transform: scale(0.97); }

/* ---- feedback grid (attribute-based games) ---- */
.feedback-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 5px;
}

.feedback-row .guess-name {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 2px 2px 0;
}

.tile {
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  color: #0b0b14;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tile .label { font-size: 0.58rem; font-weight: 600; opacity: 0.75; }

.tile.hit { background: var(--hit); color: #05170c; }
.tile.close { background: var(--close); color: #241b02; }
.tile.miss { background: var(--miss); color: var(--text-dim); }

.tile .arrow { font-size: 0.75rem; }

/* ---- juice: tile reveal + wrong-guess shake + win celebration ---- */
@keyframes tile-pop {
  0% { transform: scale(0.4) rotateX(90deg); opacity: 0; }
  60% { transform: scale(1.08) rotateX(0deg); opacity: 1; }
  100% { transform: scale(1) rotateX(0deg); }
}

.feedback-row.is-new .tile {
  animation: tile-pop 0.32s ease backwards;
}

.feedback-row.is-new .tile:nth-child(2) { animation-delay: 0.03s; }
.feedback-row.is-new .tile:nth-child(3) { animation-delay: 0.06s; }
.feedback-row.is-new .tile:nth-child(4) { animation-delay: 0.09s; }
.feedback-row.is-new .tile:nth-child(5) { animation-delay: 0.12s; }
.feedback-row.is-new .tile:nth-child(6) { animation-delay: 0.15s; }
.feedback-row.is-new .tile:nth-child(7) { animation-delay: 0.18s; }

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

.feedback-row.is-wrong { animation: shake-row 0.4s ease; }

.guess-history .row.is-new { animation: shake-row 0.4s ease; }
.guess-history .row.right.is-new { animation: tile-pop 0.32s ease; }

@keyframes result-pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-panel { animation: result-pop 0.25s ease; }

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}

@keyframes confetti-burst {
  0% { transform: translate(0, 0) scale(0.6); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

.confetti-piece {
  position: absolute;
  font-size: 1.4rem;
  animation: confetti-burst 0.9s ease-out forwards;
}

/* ---- lyric / emoji game text panels ---- */
.clue-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}

.clue-panel .emoji-display {
  font-size: 2.4rem;
  letter-spacing: 4px;
}

.clue-panel .hint-text {
  font-size: 1.05rem;
  line-height: 1.5;
  font-style: italic;
}

.clue-panel .hint-extra {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

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

.guess-history .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.guess-history .row.wrong { border-color: var(--miss); }
.guess-history .row.right { border-color: var(--hit); }

/* ---- result panel ---- */
.result-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-panel h2 { margin: 0; }

.result-grid-preview {
  font-family: monospace;
  font-size: 1.4rem;
  line-height: 1.3;
  white-space: pre;
}

.stats-row {
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.stats-row .stat .num { font-size: 1.3rem; font-weight: 800; }
.stats-row .stat .lbl { font-size: 0.7rem; color: var(--text-dim); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; }

.archive-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

@keyframes badge-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.rank-pill.is-new, .streak-badge.is-new { animation: badge-pop 0.35s ease; }

/* ---- challenge banner (Create & Challenge) ---- */
.challenge-banner {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.challenge-banner a { color: white; text-decoration: underline; font-weight: 500; font-size: 0.78rem; white-space: nowrap; }

/* ---- create-a-challenge page ---- */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.mode-tab {
  padding: 10px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-align: center;
  cursor: pointer;
}

.mode-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-elevated);
}

.link-box {
  display: flex;
  gap: 8px;
}

.link-box input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 0.82rem;
}

.link-box button {
  white-space: nowrap;
  padding: 0 16px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  cursor: pointer;
}

footer.site-footer {
  margin-top: auto;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  padding-top: 12px;
}

footer.site-footer a { color: var(--text-dim); text-decoration: underline; }
