/* ── Design tokens ──────────────────────────────── */
:root {
  --bg:         #0f0a0e;
  --bg-card:    rgba(255, 255, 255, 0.04);
  --rose:       #c9788a;
  --rose-light: #dfa0af;
  --gold:       #e8c4a0;
  --text:       #f5f0ee;
  --text-muted: #9a8f8c;
  --border:     rgba(201, 120, 138, 0.2);
  --blur:       blur(12px);
  --radius:     16px;
  --radius-sm:  8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ─────────────────────────────────── */
h1, h2, h3 { font-family: 'Playfair Display', serif; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }

/* ── Canvas background ──────────────────────────── */
#bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.4; }

/* ── Layout ─────────────────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 2rem 1rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.screen.active { display: flex; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  padding: 2.5rem;
  width: 100%;
  max-width: 480px;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-light));
  color: white;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(201,120,138,0.35); }
.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ── Input ──────────────────────────────────────── */
.input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}
.input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(201,120,138,0.15); }
.input::placeholder { color: var(--text-muted); }

/* ── Countdown timer ────────────────────────────── */
.timer {
  display: flex;
  gap: 0.2rem;
  justify-content: center;
  align-items: flex-end;
  margin: 2rem 0;
}
.timer-unit { text-align: center; }
.timer-digit {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 700;
  color: var(--rose);
  line-height: 1;
  display: block;
  min-width: 2ch;
}
.timer-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.25rem;
}
.timer-sep {
  font-size: clamp(2rem, 6vw, 4rem);
  color: var(--rose);
  opacity: 0.4;
  line-height: 1;
  margin-bottom: 0.4rem;
}

/* ── Flip animation ─────────────────────────────── */
@keyframes flip-down {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}
.timer-digit.flipping { animation: flip-down 0.35s ease-in-out; }

/* ── Hint box ────────────────────────────────────── */
.hint-box {
  background: linear-gradient(135deg, rgba(201,120,138,0.1), rgba(232,196,160,0.08));
  border: 1px solid var(--rose);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  text-align: center;
  animation: fadeSlideIn 0.6s ease both;
}
.hint-label { font-size: 0.75rem; color: var(--rose); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 0.5rem; }
.hint-text  { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--gold); }

/* ── Key unlock animation ────────────────────────── */
.key-unlock {
  text-align: center;
  padding: 2rem;
  animation: keyBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.key-icon { font-size: 4rem; display: block; margin-bottom: 1rem; }
@keyframes keyBounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── General animations ─────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeSlideIn 0.5s ease both; }

/* ── Rules screen ────────────────────────────────── */
.rules-list { list-style: none; margin: 1.5rem 0; display: flex; flex-direction: column; gap: 1rem; }
.rules-list li {
  display: flex; gap: 1rem; align-items: flex-start;
  font-size: 0.95rem; line-height: 1.5; color: var(--text-muted);
}
.rules-list li span.icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 0.1rem; }

/* ── Mosaic game ─────────────────────────────────── */
.mosaic-grid {
  display: grid;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.mosaic-block {
  aspect-ratio: 1;
  background: #0f0a0e;
  cursor: default;
  position: relative;
  overflow: hidden;
}
.mosaic-cover {
  position: absolute;
  inset: 0;
  background: #1a0f14;
  transition: opacity 0.4s ease;
}
.mosaic-cover.hidden { opacity: 0; pointer-events: none; }

/* ── Wordle game ─────────────────────────────────── */
.wordle-grid { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-bottom: 1.5rem; }
.wordle-row  { display: flex; gap: 6px; }
.wordle-cell {
  width: 52px; height: 52px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; text-transform: uppercase;
  transition: var(--transition);
}
.wordle-cell.correct  { background: #3a7d44; border-color: #3a7d44; color: white; }
.wordle-cell.present  { background: #b59f3b; border-color: #b59f3b; color: white; }
.wordle-cell.absent   { background: #3a3a3c; border-color: #3a3a3c; color: white; }
.wordle-cell.filled   { border-color: var(--text-muted); }

.wordle-keyboard { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.wordle-keyboard-row { display: flex; gap: 4px; }
.wordle-key {
  padding: 0.6rem 0.5rem;
  min-width: 36px;
  background: rgba(255,255,255,0.1);
  border: none; border-radius: 4px;
  color: var(--text);
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  cursor: pointer; transition: var(--transition);
}
.wordle-key:hover { background: rgba(255,255,255,0.18); }
.wordle-key.correct { background: #3a7d44; }
.wordle-key.present { background: #b59f3b; }
.wordle-key.absent  { background: #3a3a3c; }
.wordle-key.wide    { min-width: 56px; }

/* ── Memory game ─────────────────────────────────── */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1;
  perspective: 600px;
  cursor: pointer;
}
.memory-card-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
  border-radius: var(--radius-sm);
}
.memory-card.flipped .memory-card-inner { transform: rotateY(180deg); }
.memory-card.matched .memory-card-inner { transform: rotateY(180deg); }
.memory-card-front,
.memory-card-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.memory-card-front {
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.memory-card-front::after { content: '?'; font-size: 1.5rem; color: var(--rose); opacity: 0.6; }
.memory-card-back {
  background: linear-gradient(135deg, rgba(201,120,138,0.15), rgba(232,196,160,0.1));
  border: 1px solid var(--rose);
  transform: rotateY(180deg);
}
.memory-card.matched .memory-card-back {
  background: linear-gradient(135deg, rgba(58,125,68,0.3), rgba(58,125,68,0.2));
  border-color: #3a7d44;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 500px) {
  .card { padding: 1.5rem; }
  .wordle-cell { width: 44px; height: 44px; }
  .wordle-key  { padding: 0.5rem 0.4rem; min-width: 30px; font-size: 0.72rem; }
}
