/* ═══════════════════════════════════════════════════════════
   DoodleDash — Sketchbook Orange/Yellow Theme
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --primary:        #FF8A1F;
  --primary-hover:  #E0700F;
  --primary-light:  #FFF0DB;
  --primary-dark:   #C25A00;
  --yellow:         #FFD447;
  --yellow-dark:    #F5C200;
  --yellow-light:   #FFF8DC;
  --cream:          #FFFDF5;
  --paper:          #FFFCF0;
  --ink:            #3B2414;
  --ink-mid:        #5C3D26;
  --ink-light:      #8B6B52;
  --ink-faint:      #C4A882;
  --danger:         #E8453C;
  --danger-light:   #FEE2E2;
  --success:        #2D9B50;
  --success-light:  #DCFCE7;
  --warning:        #F59E0B;
  --correct-green:  #538D4E;
  --misplaced-yellow: #B59F3B;
  --wrong-gray:     #818384;
  --bg:             #FFF4CC;
  --bg-pattern:     url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23FFD447' fill-opacity='0.15'%3E%3Ccircle cx='20' cy='20' r='2'/%3E%3C/g%3E%3C/svg%3E");
  --card:           #FFFDF5;
  --card-border:    #EDD9A3;
  --border:         #E8D5A8;
  --border-light:   #F2E8CC;
  --shadow:         0 2px 10px rgba(59,36,20,0.08), 0 1px 3px rgba(59,36,20,0.06);
  --shadow-md:      0 4px 16px rgba(59,36,20,0.10), 0 2px 6px rgba(59,36,20,0.07);
  --shadow-lg:      0 8px 32px rgba(59,36,20,0.13), 0 4px 12px rgba(59,36,20,0.09);
  --shadow-inset:   inset 0 2px 4px rgba(59,36,20,0.08);
  --radius:         16px;
  --radius-sm:      10px;
  --radius-xs:      6px;
  --font:           'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --transition:     all 0.18s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══ SCREENS ══════════════════════════════════════════════ */
.screen { display: none; max-width: 660px; margin: 0 auto; padding: 16px; min-height: 100vh; }
.screen.active { display: block; animation: screenIn 0.28s cubic-bezier(.4,0,.2,1); }
@keyframes screenIn { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:none; } }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.18)} 70%{transform:scale(.96)} 100%{transform:scale(1)} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes wiggle { 0%,100%{transform:rotate(-2deg)} 50%{transform:rotate(2deg)} }
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:none} }
@keyframes slideDown { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:none} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes glow { 0%,100%{box-shadow:0 0 8px var(--primary)} 50%{box-shadow:0 0 20px var(--primary), 0 0 40px var(--yellow)} }
@keyframes confettiDrop { from{opacity:1;transform:translateY(-20px) rotate(0)} to{opacity:0;transform:translateY(80px) rotate(720deg)} }
.shake { animation: shake 0.42s ease; }
.pop { animation: pop 0.4s cubic-bezier(.4,0,.2,1); }
.bounce { animation: bounce 0.6s ease; }

/* ══ CARDS ════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
  border: 1.5px solid var(--card-border);
  position: relative;
}

/* Sketchbook torn-edge effect on cards */
.card::before {
  content: '';
  position: absolute;
  top: -1px; left: 12px; right: 12px;
  height: 3px;
  background: repeating-linear-gradient(90deg, transparent, transparent 4px, var(--yellow) 4px, var(--yellow) 8px);
  border-radius: 3px 3px 0 0;
  opacity: 0.6;
}

/* ══ BUTTONS ══════════════════════════════════════════════ */
button {
  cursor: pointer; border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px; font-weight: 700;
  padding: 11px 18px;
  transition: var(--transition);
  letter-spacing: 0.01em;
}
button:active { transform: scale(0.95); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, #FF9A35 0%, #FF7A0F 100%);
  color: white;
  box-shadow: 0 3px 10px rgba(255,122,15,0.35), 0 1px 3px rgba(255,122,15,0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.btn-primary:hover { background: linear-gradient(135deg, #FFA845 0%, #E86900 100%); box-shadow: 0 4px 14px rgba(255,122,15,0.45); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.97); box-shadow: 0 1px 4px rgba(255,122,15,0.3); }
.btn-primary:disabled { background: linear-gradient(135deg, #FFCC99, #FFBB77); box-shadow: none; cursor: not-allowed; transform: none; color: rgba(255,255,255,0.7); }

.btn-ghost {
  background: var(--yellow-light);
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--yellow); border-color: var(--yellow-dark); }

.btn-danger {
  background: linear-gradient(135deg, #F55A52 0%, #D93830 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(217,56,48,0.3);
}
.btn-danger:hover { background: linear-gradient(135deg, #E04840 0%, #C02820 100%); }

.btn-success {
  background: linear-gradient(135deg, #3DB868 0%, #2A8B4A 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(42,139,74,0.3);
}

.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-back { background: none; color: var(--primary); padding: 6px 0; font-size: 14px; font-weight: 700; }
.btn-back:hover { text-decoration: underline; transform: none; }
.btn-full { width: 100%; margin-top: 10px; padding: 14px; font-size: 16px; }

/* ══ INPUTS ═══════════════════════════════════════════════ */
input[type=text], input[type=password] {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  background: white;
  color: var(--ink);
}
input[type=text]:focus, input[type=password]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,138,31,0.15);
}
input::placeholder { color: var(--ink-faint); }

/* ══ AUTH SCREENS ════════════════════════════════════════ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 40px 36px 32px;
  border-radius: 24px;
  background: var(--card);
  border: 2px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.auth-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--yellow) 0%, var(--primary) 50%, var(--yellow) 100%);
}

.logo-wrap { margin-bottom: 6px; }
.logo-text {
  font-size: 38px;
  font-weight: 900;
  background: linear-gradient(135deg, #FF7A0F 0%, #FF9A35 50%, #FFD447 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  display: block;
  line-height: 1;
}
.logo-pencil { font-size: 30px; }
.tagline {
  color: var(--ink-light);
  margin-bottom: 28px;
  font-size: 14px;
  font-weight: 600;
}
.auth-card form input { margin-bottom: 10px; }
.auth-card button { width: 100%; margin-top: 4px; padding: 14px; font-size: 16px; }
.auth-link { margin-top: 18px; font-size: 14px; color: var(--ink-light); }
.auth-link a { color: var(--primary); text-decoration: none; font-weight: 700; }
.auth-link a:hover { text-decoration: underline; }
.error-msg { color: var(--danger); font-size: 13px; font-weight: 600; margin-top: 10px; min-height: 20px; }

/* Auth decoration dots */
.auth-dots {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 24px;
}
.auth-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow);
  animation: bounce 1.2s ease infinite;
}
.auth-dot:nth-child(2) { animation-delay: 0.15s; background: var(--primary); }
.auth-dot:nth-child(3) { animation-delay: 0.3s; background: var(--yellow-dark); }

/* ══ DASHBOARD ════════════════════════════════════════════ */
.dash-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: linear-gradient(135deg, #FF9A35 0%, #FF7208 50%, #E86000 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 20px rgba(255,122,15,0.4);
}
.dash-header::before { display: none; }
.avatar-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.5);
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.dash-username { font-size: 18px; font-weight: 900; color: white; }
.dash-since { font-size: 12px; color: rgba(255,255,255,0.75); font-weight: 600; }
.dash-stats { display: flex; gap: 8px; }
.stat-pill {
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  font-weight: 700;
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  backdrop-filter: blur(4px);
}
.dash-actions-header { display: flex; gap: 8px; margin-left: auto; }
.dash-actions-header button {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.35);
  font-size: 13px;
  padding: 7px 12px;
  font-weight: 700;
}
.dash-actions-header button:hover { background: rgba(255,255,255,0.35); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.section-header h2 { font-size: 17px; font-weight: 800; color: var(--ink); }
.empty-msg { color: var(--ink-light); font-size: 14px; padding: 12px 4px; font-weight: 600; }

/* ══ FRIENDS ══════════════════════════════════════════════ */
.friend-request-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #FFF8E0, #FFFDF0);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1.5px solid var(--yellow);
  animation: slideDown 0.3s ease;
}
.friend-request-item .fr-name { flex: 1; font-weight: 700; font-size: 14px; }
.friend-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-light);
}
.friend-item:last-child { border-bottom: none; }
.friend-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--yellow-light));
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px; flex-shrink: 0;
  border: 2px solid var(--primary-light);
}
.friend-name { flex: 1; font-weight: 700; font-size: 14px; }
.friend-status-label { font-size: 12px; color: var(--ink-light); font-style: italic; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 4px; }
.offline-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); margin-right: 4px; }

/* ══ MODALS ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(59,36,20,0.4);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.modal { width: 100%; max-width: 400px; margin: 0; animation: pop 0.3s ease; }
.modal h2 { margin-bottom: 8px; font-size: 20px; font-weight: 900; }
.modal p { color: var(--ink-light); font-size: 14px; margin-bottom: 16px; font-weight: 600; }
.modal input { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }
.msg-box { margin-top: 12px; font-size: 13px; font-weight: 700; min-height: 18px; text-align: center; }
.msg-box.success { color: var(--success); }
.msg-box.error { color: var(--danger); }

/* Invite code display */
.invite-code-box {
  background: linear-gradient(135deg, var(--primary-light), var(--yellow-light));
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  margin-top: 12px;
}
.invite-code-label { font-size: 12px; font-weight: 700; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.1em; }
.invite-code-value { font-size: 36px; font-weight: 900; color: var(--primary); letter-spacing: 0.3em; margin: 6px 0; }
.invite-code-hint { font-size: 12px; color: var(--ink-light); }

/* ══ GAME CARDS ═══════════════════════════════════════════ */
.game-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 10px;
  background: white;
  position: relative;
  overflow: hidden;
}
.game-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--border);
  border-radius: 3px 0 0 3px;
}
.game-card:hover { border-color: var(--primary); transform: translateX(2px); box-shadow: var(--shadow-md); }
.game-card.my-turn { border-color: var(--primary); background: linear-gradient(135deg, #FFF8F0, #FFFCF5); }
.game-card.my-turn::after { background: linear-gradient(180deg, var(--primary), var(--yellow)); }
.game-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.game-opp { font-weight: 800; font-size: 15px; }
.game-card-status { font-size: 12px; font-weight: 700; }
.game-card-status.your-turn { color: var(--primary); }
.game-card-status.waiting { color: var(--ink-light); }
.game-card-meta { display: flex; gap: 14px; font-size: 12px; color: var(--ink-light); font-weight: 600; }
.game-card-meta span { display: flex; align-items: center; gap: 3px; }

/* ══ SCREEN HEADER ════════════════════════════════════════ */
.screen-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.screen-header h2 { font-size: 22px; font-weight: 900; }
.hint-text { color: var(--ink-light); font-size: 14px; margin-bottom: 14px; font-weight: 600; }

/* ══ WORD CARDS ═══════════════════════════════════════════ */
.word-cards { display: grid; gap: 12px; margin-bottom: 14px; }
.word-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 2.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background: white;
  position: relative;
  overflow: hidden;
}
.word-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
  background: linear-gradient(135deg, var(--primary-light), var(--yellow-light));
}
.word-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.word-card:hover::before { opacity: 0.5; }
.word-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,138,31,0.2); }
.word-card.selected::before { opacity: 1; }
.wc-left { flex: 1; position: relative; }
.wc-word { font-size: 22px; font-weight: 900; color: var(--ink); margin-bottom: 4px; letter-spacing: -0.3px; }
.wc-diff { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.06em; text-transform: uppercase; }
.wc-diff.easy { background: #D1FAE5; color: #065F46; }
.wc-diff.medium { background: #FEF3C7; color: #92400E; }
.wc-diff.hard { background: #FEE2E2; color: #991B1B; }
.wc-desc { font-size: 12px; color: var(--ink-light); font-weight: 600; margin-top: 4px; }
.wc-pts { font-size: 28px; font-weight: 900; color: var(--primary); text-align: right; line-height: 1; position: relative; }
.wc-pts small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-light); }

/* ══ GAME HEADER ══════════════════════════════════════════ */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-mid) 100%);
  border: none;
  box-shadow: 0 3px 12px rgba(59,36,20,0.2);
}
.game-header::before { display: none; }
.word-display { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.badge-diff {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-diff.easy { background: rgba(49,196,141,0.25); color: #5EFFC5; border: 1px solid rgba(49,196,141,0.4); }
.badge-diff.medium { background: rgba(255,212,71,0.25); color: #FFE57A; border: 1px solid rgba(255,212,71,0.4); }
.badge-diff.hard { background: rgba(255,90,90,0.25); color: #FF8080; border: 1px solid rgba(255,90,90,0.4); }
.secret-word { font-size: 22px; font-weight: 900; color: var(--yellow); letter-spacing: -0.3px; }
.pts-badge { font-size: 13px; font-weight: 800; color: rgba(255,255,255,0.7); }

/* ══ CANVAS ════════════════════════════════════════════════ */
.canvas-wrap {
  position: relative;
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-inset), 0 2px 8px rgba(59,36,20,0.1);
  border: 2px solid var(--border);
  margin-bottom: 10px;
  /* Lined-paper effect */
  background-image: repeating-linear-gradient(transparent, transparent 27px, #EEE8D8 27px, #EEE8D8 28px);
  background-position: 0 28px;
}
#draw-canvas, #guess-canvas {
  display: block;
  width: 100%;
  touch-action: none;
  background: transparent;
}
#draw-canvas { height: clamp(280px, 48vw, 400px); }
.guess-canvas-wrap canvas { height: clamp(240px, 44vw, 360px); cursor: default; }

/* Canvas empty state */
.canvas-empty-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0.3;
  font-size: 14px; font-weight: 700; color: var(--ink-light);
}

/* ══ TOOLBAR ══════════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  justify-content: center;
  background: var(--card);
}
.tool-group { display: flex; gap: 5px; }
.tool-btn {
  background: var(--yellow-light);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 18px;
  border-radius: var(--radius-xs);
  border: 2px solid var(--border);
  width: auto;
  transition: var(--transition);
}
.tool-btn:hover { background: var(--yellow); border-color: var(--yellow-dark); }
.tool-btn.active {
  background: linear-gradient(135deg, #FF9A35, #FF7208);
  border-color: var(--primary-dark);
  color: white;
  box-shadow: 0 2px 8px rgba(255,122,15,0.35);
}
.color-group { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2.5px solid transparent;
  flex-shrink: 0; transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: var(--ink); transform: scale(1.25); box-shadow: 0 0 0 2px white inset, 0 2px 8px rgba(0,0,0,0.3); }
.size-group { display: flex; gap: 4px; align-items: center; }
.size-btn {
  background: var(--yellow-light);
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 9px;
  font-size: 12px; font-weight: 800; cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  color: var(--ink);
}
.size-btn:hover { background: var(--yellow); }
.size-btn.active { background: var(--ink); color: white; border-color: var(--ink); }

/* ══ PLAYBACK CONTROLS ════════════════════════════════════ */
.playback-controls {
  display: flex; align-items: center; gap: 6px;
  justify-content: center; flex-wrap: wrap;
  padding: 10px 14px;
}
.speed-btn { min-width: 44px; font-size: 13px; }
.speed-btn.active { background: linear-gradient(135deg, #FF9A35, #FF7208); color: white; border-color: var(--primary-dark); }

/* ══ GUESS AREA ═══════════════════════════════════════════ */
.guess-area { padding: 14px 16px; }
.guess-feedback {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  margin-bottom: 12px; text-align: center;
  animation: slideDown 0.25s ease;
}
.guess-feedback.wrong { background: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.guess-feedback.correct { background: var(--success-light); color: #14532D; border: 1px solid #BBF7D0; }
.guess-feedback.hidden { display: none; }
.guess-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.guess-input-row button { white-space: nowrap; flex-shrink: 0; padding: 12px 20px; font-size: 15px; }
.attempts-label { font-size: 13px; color: var(--ink-light); margin-top: 8px; text-align: center; font-weight: 700; }

/* ══ LETTER TILES (Wordle-style) ══════════════════════════ */
.guess-rows-wrap { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.guess-row { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-bottom: 4px; animation: slideDown 0.2s ease; }
.letter-tile {
  width: 38px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
  border-radius: var(--radius-xs);
  border: 2.5px solid var(--border);
  background: white; color: var(--ink);
  text-transform: uppercase;
  transition: border-color 0.15s, background 0.3s, transform 0.15s;
  user-select: none;
}
.letter-tile.filled { border-color: var(--ink-light); transform: scale(1.03); }
.letter-tile.correct { background: var(--correct-green); color: white; border-color: var(--correct-green); animation: pop 0.4s ease; }
.letter-tile.misplaced { background: var(--misplaced-yellow); color: white; border-color: var(--misplaced-yellow); animation: pop 0.4s ease 0.05s; }
.letter-tile.wrong { background: var(--wrong-gray); color: white; border-color: var(--wrong-gray); animation: pop 0.4s ease 0.1s; }
.letter-tile.empty { border-style: dashed; opacity: 0.45; }

/* Word blanks display */
.guess-blanks {
  font-size: 20px; font-weight: 800; color: var(--yellow);
  letter-spacing: 0.15em; margin-left: 8px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

/* ══ KEYBOARD ══════════════════════════════════════════════ */
.keyboard { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; padding: 0 2px; }
.keyboard-row { display: flex; gap: 4px; justify-content: center; }
.key-btn {
  min-width: 33px; height: 48px; padding: 0 6px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--yellow-light);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px; font-weight: 800;
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 var(--border);
}
.key-btn:hover { background: var(--yellow); border-color: var(--yellow-dark); transform: translateY(-1px); box-shadow: 0 3px 0 var(--yellow-dark); }
.key-btn:active { transform: translateY(1px); box-shadow: none; }
.key-btn.wide { min-width: 56px; font-size: 12px; }
.key-btn.correct { background: var(--correct-green); color: white; border-color: var(--correct-green); box-shadow: 0 2px 0 #396836; }
.key-btn.misplaced { background: var(--misplaced-yellow); color: white; border-color: var(--misplaced-yellow); box-shadow: 0 2px 0 #8B7A2A; }
.key-btn.wrong { background: var(--wrong-gray); color: white; border-color: var(--wrong-gray); box-shadow: 0 2px 0 #5a5a5a; }

/* ══ RESULT SCREEN ════════════════════════════════════════ */
.result-wrap { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.result-card { text-align: center; padding: 40px 28px; max-width: 400px; margin: 0 auto; }
.result-emoji { font-size: 72px; margin-bottom: 8px; animation: bounce 0.8s ease; display: block; }
.result-card h2 { font-size: 32px; font-weight: 900; margin-bottom: 6px; }
.result-word { font-size: 16px; color: var(--ink-light); margin-bottom: 24px; font-weight: 600; }
.result-word strong { color: var(--ink); }
.result-stats { display: flex; justify-content: center; gap: 14px; margin-bottom: 18px; }
.result-stat {
  background: var(--yellow-light);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  min-width: 100px;
  border: 2px solid var(--border);
  transition: var(--transition);
}
.result-stat.pop { animation: pop 0.5s cubic-bezier(.4,0,.2,1); }
.result-stat-label { display: block; font-size: 12px; color: var(--ink-light); margin-bottom: 4px; font-weight: 700; }
.result-stat-val { display: block; font-size: 30px; font-weight: 900; color: var(--primary); }
.result-bonus {
  background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
  color: #065F46;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 800;
  margin-bottom: 18px;
  border: 1.5px solid #6EE7B7;
  animation: glow 2s ease infinite;
}
.result-card button { width: 100%; margin-bottom: 10px; padding: 14px; font-size: 15px; }

/* Confetti */
.confetti-piece {
  position: fixed;
  top: -20px;
  width: 10px; height: 10px;
  border-radius: 2px;
  animation: confettiDrop 2.5s ease forwards;
  z-index: 9999;
  pointer-events: none;
}

/* ══ STATS SCREEN ═════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  text-align: center;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .val { font-size: 28px; font-weight: 900; color: var(--primary); display: block; line-height: 1.1; }
.stat-card .lbl { font-size: 12px; color: var(--ink-light); margin-top: 4px; display: block; font-weight: 700; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.diff-table th, .diff-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-light); }
.diff-table th { color: var(--ink-light); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.diff-table tr:last-child td { border-bottom: none; }
.diff-table td:not(:first-child) { font-weight: 700; color: var(--ink); }

/* ══ HISTORY ══════════════════════════════════════════════ */
.history-item {
  padding: 14px 6px;
  border-bottom: 1.5px solid var(--border-light);
  display: flex; gap: 12px; align-items: flex-start;
  transition: var(--transition);
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--yellow-light); border-radius: var(--radius-xs); padding: 14px 10px; }
.history-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.history-info { flex: 1; min-width: 0; }
.history-word { font-weight: 800; font-size: 15px; }
.history-meta { font-size: 12px; color: var(--ink-light); margin-top: 2px; font-weight: 600; }
.history-result { font-size: 13px; font-weight: 700; margin-top: 3px; }
.history-result.correct { color: var(--success); }
.history-result.failed { color: var(--danger); }
.history-pts { font-size: 14px; color: var(--primary); font-weight: 800; text-align: right; white-space: nowrap; flex-shrink: 0; }

/* History replay mini-button */
.btn-replay-mini {
  font-size: 11px; padding: 4px 8px;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid var(--primary-light);
  border-radius: 4px; font-weight: 700;
  cursor: pointer; transition: var(--transition);
  font-family: var(--font);
}
.btn-replay-mini:hover { background: var(--primary); color: white; }

/* ══ NOTIFICATIONS ════════════════════════════════════════ */
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 900;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--primary);
  animation: bounce 1s ease infinite;
}
.notif-badge.hidden { display: none; }
.notif-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: var(--transition);
}
.notif-item:hover { background: var(--yellow-light); }
.notif-item.unread { background: linear-gradient(135deg, var(--primary-light), var(--yellow-light)); }
.notif-item:last-child { border-bottom: none; }
.notif-msg { font-size: 14px; font-weight: 600; }
.notif-time { font-size: 11px; color: var(--ink-light); margin-top: 2px; font-weight: 600; }
.notif-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* ══ TOAST ════════════════════════════════════════════════ */
.toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.3s ease;
  max-width: 320px;
  pointer-events: all;
  display: flex; align-items: center; gap: 8px;
  border-left: 4px solid var(--yellow);
}
.toast.success { background: var(--success); border-left-color: #A7F3D0; }
.toast.error { background: var(--danger); border-left-color: #FECACA; }
.toast.info { background: var(--primary); border-left-color: var(--yellow); }

/* ══ RESPONSIVE — MOBILE ══════════════════════════════════ */
@media (max-width: 520px) {
  .screen { padding: 10px; }
  .auth-card { padding: 32px 24px 24px; }
  .logo-text { font-size: 32px; }
  .dash-header { gap: 8px; padding: 12px 14px; }
  .dash-actions-header { width: 100%; justify-content: flex-end; }
  .dash-username { font-size: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card .val { font-size: 22px; }
  .game-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .secret-word { font-size: 18px; }
  .toolbar { gap: 6px; padding: 8px 10px; }
  .tool-btn { padding: 7px 10px; font-size: 16px; }
  .color-swatch { width: 24px; height: 24px; }
  #draw-canvas { height: clamp(220px, 56vw, 300px); }
  .guess-canvas-wrap canvas { height: clamp(200px, 50vw, 280px); }
  .letter-tile { width: 30px; height: 36px; font-size: 17px; }
  .key-btn { min-width: 28px; height: 44px; font-size: 14px; padding: 0 4px; }
  .key-btn.wide { min-width: 48px; font-size: 11px; }
  .toast-container { right: 8px; left: 8px; }
  .toast { max-width: 100%; }
  .result-emoji { font-size: 56px; }
  .result-card h2 { font-size: 26px; }
  .result-stat { padding: 12px 14px; min-width: 80px; }
  .result-stat-val { font-size: 24px; }
  .wc-word { font-size: 18px; }
  .wc-pts { font-size: 22px; }
}

/* ══ RESPONSIVE — DESKTOP ═════════════════════════════════ */
@media (min-width: 640px) {
  .screen { padding: 24px 20px; }
  .dash-content { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .dash-content > .section-card:first-child { grid-column: 1 / -1; }
}

/* ══ UTILITY ══════════════════════════════════════════════ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--ink-light); }
.fw-bold { font-weight: 800; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* ══ ACTIVITY / RECENT ════════════════════════════════════ */
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-light);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 20px; flex-shrink: 0; }
.activity-info { flex: 1; min-width: 0; }
.activity-title { font-size: 14px; font-weight: 700; }
.activity-meta { font-size: 12px; color: var(--ink-light); font-weight: 600; }

/* ══ STREAK DISPLAY ═══════════════════════════════════════ */
.streak-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #FFF3DC, #FFF8ED);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--yellow);
  margin-bottom: 8px;
}
.streak-flames { font-size: 18px; }
.streak-label { font-size: 13px; font-weight: 700; color: var(--ink-mid); }
.streak-value { font-size: 20px; font-weight: 900; color: var(--primary); margin-left: auto; }

/* ══ GAME SCORE DISPLAY ═══════════════════════════════════ */
.score-row {
  display: flex; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px; font-weight: 700;
}
.score-row:last-child { border-bottom: none; }
.score-name { flex: 1; }
.score-pts { color: var(--primary); font-size: 16px; font-weight: 900; }
