:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}

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

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

/* ---------- Shared ---------- */
.hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.5px;
  padding: 14px 0 18px;
}

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.topbar-back { color: var(--accent); font-size: 15px; font-weight: 600; min-width: 56px; }
.topbar-title { flex: 1; text-align: center; font-size: 22px; font-weight: 700; }
.topbar-count { min-width: 56px; text-align: right; color: var(--text-secondary); font-size: 15px; font-weight: 600; }

/* ---------- Home ---------- */
.home-hero {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 24px 32px 8px;
}
.door-badge { font-size: 104px; line-height: 1; filter: drop-shadow(0 6px 18px rgba(0,212,255,0.25)); }
.app-title { font-size: 52px; font-weight: 800; margin-top: 8px; letter-spacing: -1px; }
.app-sub { color: var(--text-secondary); font-size: 19px; margin-top: 10px; max-width: 460px; }

.home-actions {
  display: flex; flex-direction: column; gap: 14px;
  padding: 0 32px;
}
.home-btn {
  display: flex; align-items: center; gap: 18px;
  width: 100%; min-height: 88px;
  padding: 0 22px;
  background: var(--bg-secondary);
  border-radius: 16px;
  text-align: left;
}
.home-btn-primary {
  background: linear-gradient(135deg, #0e2a33, #14141f);
  border-color: rgba(0, 212, 255, 0.35);
}
.hb-emoji { font-size: 42px; flex-shrink: 0; }
.hb-text { display: flex; flex-direction: column; gap: 4px; }
.hb-text strong { font-size: 23px; font-weight: 700; color: var(--text-primary); }
.hb-text small { font-size: 14px; color: var(--text-secondary); }

.stats-bar {
  display: flex; justify-content: center; gap: 14px;
  margin: 22px 32px 0;
}
.stat {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-tertiary);
  border-radius: 14px;
  padding: 14px 8px;
}
.stat-num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-lbl { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Categories ---------- */
.cat-list {
  flex: 1;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px;
  overflow: hidden;
}
.cat-item {
  display: flex; align-items: center; gap: 18px;
  width: 100%; min-height: 82px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-radius: 16px;
  text-align: left;
}
.cat-emoji { font-size: 38px; flex-shrink: 0; }
.cat-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cat-text strong { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.cat-text small { font-size: 14px; color: var(--text-secondary); }
.cat-go { font-size: 30px; color: var(--text-muted); flex-shrink: 0; }

/* ---------- Joke stage ---------- */
.stage {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  padding: 24px 36px;
  text-align: center;
}
.knock-door { font-size: 112px; line-height: 1; }
.knock-text { font-size: 56px; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
.bubble {
  display: inline-block;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 22px; font-weight: 600;
  padding: 12px 22px;
  border-radius: 18px;
}
.who-name {
  font-size: 54px; font-weight: 800;
  color: var(--accent-secondary);
  letter-spacing: -1px;
  line-height: 1.05;
}
.punchline {
  font-size: 31px; font-weight: 700;
  line-height: 1.32;
  color: var(--text-primary);
  max-width: 520px;
}
.stage-hint { font-size: 15px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Joke actions ---------- */
.actions {
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 24px 24px;
}
.rating-hint {
  text-align: center; color: var(--text-secondary);
  font-size: 14px; margin-bottom: 2px;
}
.rating-row { display: flex; gap: 12px; }
.rating-row .act-btn { flex: 1; }
.act-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 68px;
  padding: 0 18px;
  background: var(--bg-secondary);
  border-radius: 16px;
  color: var(--text-primary);
  font-size: 21px; font-weight: 700;
}
.act-primary {
  background: linear-gradient(135deg, #0e2a33, #16202b);
  border-color: rgba(0, 212, 255, 0.35);
}
.act-rate { background: var(--bg-tertiary); }
.act-ghost {
  min-height: 54px;
  background: transparent;
  border-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 18px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(18px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 18px; font-weight: 700;
  border: 1px solid rgba(0, 212, 255, 0.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Animations ---------- */
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
.pop { animation: pop 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes knock {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-9deg); }
  40% { transform: rotate(7deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(3deg); }
}
.knock-door.pop { animation: pop 0.3s both, knock 0.65s 0.3s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .pop, .knock-door.pop { animation: none; }
  .focusable { transition: none; }
}
