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

:root {
  --bg: #fff7ed;
  --surface: #ffffff;
  --primary: #f97316;
  --text: #1a1a2e;
  --text-light: #78716c;
  --correct: #22c55e;
  --wrong: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 32px;
}

.screen { display: none; }
.screen.active { display: block; }

/* ── Category Select ── */
.logo { text-align: center; padding-top: 24px; margin-bottom: 8px; }
.logo-icon { font-size: 56px; line-height: 1; }
.logo h1 { font-size: 38px; font-weight: 800; color: var(--primary); margin-top: 4px; }
.subtitle { text-align: center; color: var(--text-light); font-size: 17px; margin-bottom: 28px; }

.mode-grid { display: flex; flex-direction: column; gap: 14px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 3px solid transparent;
  border-radius: 18px;
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.08);
}
.mode-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(249, 115, 22, 0.16); }
.mode-card:active { transform: scale(0.98); }
.mode-emoji { font-size: 38px; line-height: 1; }
.mode-name { font-size: 21px; font-weight: 700; }

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.icon-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border: none; border-radius: 12px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 22px; height: 22px; }
.category-badge {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Mood + hearts ── */
.mood { text-align: center; margin-bottom: 18px; }
.mood-face {
  font-size: 84px;
  line-height: 1;
  transition: transform 0.2s;
}
.mood-face.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-5deg); }
  75% { transform: translateX(8px) rotate(5deg); }
}
.hearts { font-size: 26px; margin-top: 8px; letter-spacing: 3px; height: 32px; }
.heart-lost { filter: grayscale(1); opacity: 0.35; }

/* ── Word ── */
.word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  margin: 0 auto 26px;
  min-height: 64px;
}
.letter-slot {
  width: 40px;
  height: 56px;
  border-bottom: 5px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 800;
  text-transform: uppercase;
}
.letter-slot.space { border-bottom: none; width: 16px; }
.letter-slot .pop-in { animation: popIn 0.25s ease; }
@keyframes popIn {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Keyboard ── */
.keyboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  max-width: 480px;
  margin: 0 auto;
}
.key {
  width: 42px;
  height: 50px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
  transition: transform 0.1s;
}
.key:active { transform: scale(0.9); }
.key.correct { background: var(--correct); color: white; box-shadow: none; }
.key.wrong { background: var(--wrong); color: white; box-shadow: none; opacity: 0.65; }
.key:disabled { cursor: default; }

@media (max-width: 380px) {
  .key { width: 38px; height: 46px; font-size: 18px; }
  .letter-slot { width: 34px; height: 50px; font-size: 32px; }
}

/* ── End overlay ── */
#win-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#win-screen.show { display: flex; }
.win-content {
  background: var(--surface);
  border-radius: 24px;
  padding: 36px 32px;
  text-align: center;
  max-width: 340px;
  width: 88%;
  animation: popUp 0.3s ease;
}
@keyframes popUp {
  0% { transform: scale(0.5); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.win-emoji { font-size: 64px; line-height: 1; }
.win-content h2 { font-size: 28px; margin: 14px 0 8px; }
.reveal { font-size: 18px; color: var(--text-light); margin-bottom: 22px; }
.reveal strong { color: var(--primary); text-transform: uppercase; }
.primary-btn, .secondary-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 10px;
}
.primary-btn { background: var(--primary); color: white; }
.primary-btn:active { transform: scale(0.97); }
.secondary-btn { background: #e5e7eb; color: var(--text); }
.secondary-btn:active { transform: scale(0.97); }
