/* ==========================================
   CCgiggle — Warm Bright Theme v3
   Setup: warm cream light
   Game: warm dark immersive
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&display=swap');

/* ── Design tokens ── */
:root {
  /* Warm palette */
  --bg-page:       #FFF8F0;   /* warm cream */
  --bg-card:       #FFFFFF;
  --bg-card-tint:  #FFF4E8;   /* warm card tint */
  --border-card:   #F0D9C0;   /* warm border */
  --shadow-card:   rgba(180,100,40,0.10);

  --accent:        #E8682A;   /* warm orange */
  --accent-dark:   #C04F18;
  --accent-light:  #FFF0E6;
  --accent2:       #F5A623;   /* amber */
  --accent2-dark:  #C07D10;

  --success:       #1D9E75;
  --success-dark:  #0d6b53;
  --success-bg:    #E6F7F1;
  --error:         #D64236;
  --error-dark:    #A02820;
  --error-bg:      #FEF0EF;

  --text-primary:  #2C1810;   /* warm dark brown */
  --text-body:     #4A3020;   /* medium warm brown */
  --text-muted:    #9A7A6A;   /* warm grey-brown */
  --text-faint:    #C4A898;

  /* Game screen (dark warm) */
  --game-bg:       #1E0E04;   /* warm near-black */
  --game-mid:      #2E1808;
  --game-card:     #FFFFFF;
  --game-border:   rgba(255,180,100,0.15);
  --game-text:     rgba(255,240,220,0.90);
  --game-muted:    rgba(255,200,140,0.55);
}

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

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: #FFF8F0;
  min-height: 100vh;
  padding: 0 0 16px;
  max-width: 600px;
  margin: 0 auto;
  color: #2C1810;
}

/* ── Screens ── */
.screen { display: none; padding: 0 14px; }
.screen.active { display: block; }

/* ── Game screens get dark warm bg ── */
#s-game, #s-loading, #s-prologue {
  background: #FFF8F0;
  min-height: 100vh;
  padding: 0 14px;
}
#s-result, #s-leaderboard {
  background: #FFF8F0;
  min-height: 100vh;
  padding: 0 14px;
}

/* ── Top nav bar ── */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin-bottom: 2px;
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #E8682A, #F5A623);
  box-shadow: 0 2px 10px rgba(232,104,42,0.35);
}
.top-bar-logo {
  font-size: 20px; font-weight: 900; letter-spacing: -0.5px;
  color: #FFFFFF; text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.top-bar-right { display: flex; align-items: center; gap: 8px; }

/* ── Hamburger ── */
.hamburger {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}
.hamburger span { display: block; width: 15px; height: 2px; background: #fff; border-radius: 1px; }

/* ── Sidebar overlay ── */
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(44,24,16,0.5);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: all; }

.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(300px, 88vw); background: #2C1810;
  border-left: 1px solid rgba(255,180,100,0.15);
  z-index: 201; transform: translateX(110%);
  transition: transform 0.24s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,180,100,0.12); flex-shrink: 0;
  background: linear-gradient(135deg, #E8682A, #F5A623);
}
.sidebar-title { font-size: 15px; font-weight: 800; color: #fff; }
.sidebar-close { background: none; border: none; color: rgba(255,255,255,0.8); font-size: 22px; cursor: pointer; }
.sidebar-body { padding: 14px 18px; flex: 1; }
.sidebar-section { margin-bottom: 20px; }
.sidebar-section-title {
  font-size: 10px; font-weight: 800; color: rgba(255,200,140,0.6);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.sidebar-auth-logged { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #E8682A, #F5A623);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 900; color: #fff; flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 800; color: rgba(255,240,220,0.95); }
.sidebar-user-email { font-size: 11px; color: rgba(255,200,140,0.55); margin-top: 1px; }
.sidebar-btn {
  width: 100%; padding: 10px 13px; border-radius: 10px;
  border: 1px solid rgba(255,180,100,0.15); background: rgba(255,255,255,0.06);
  color: rgba(255,240,220,0.85); font-size: 13px; font-weight: 700;
  cursor: pointer; text-align: left; display: flex; align-items: center; gap: 8px;
  transition: background 0.12s; margin-bottom: 5px; font-family: inherit;
}
.sidebar-btn:hover { background: rgba(255,180,100,0.12); }
.sidebar-btn.danger { color: #F97474; border-color: rgba(249,116,116,0.2); }
.sidebar-btn.primary { background: rgba(232,104,42,0.2); border-color: rgba(232,104,42,0.4); color: #FFBF8A; }
.lang-pills { display: flex; gap: 5px; }
.lang-pill {
  flex: 1; padding: 7px; border-radius: 8px;
  border: 1.5px solid rgba(255,180,100,0.2); background: rgba(255,255,255,0.05);
  color: rgba(255,200,140,0.7); font-size: 12px; font-weight: 700;
  cursor: pointer; text-align: center; font-family: inherit;
}
.lang-pill.active { border-color: #F5A623; background: rgba(245,166,35,0.15); color: #F5A623; }
.grade-pills { display: grid; grid-template-columns: repeat(2,1fr); gap: 5px; }
.grade-pill {
  padding: 8px 6px; border-radius: 9px;
  border: 1.5px solid rgba(255,180,100,0.15); background: rgba(255,255,255,0.05);
  color: rgba(255,220,180,0.75); font-size: 12px; font-weight: 700;
  cursor: pointer; text-align: center; font-family: inherit;
}
.grade-pill .grade-age { font-size: 9px; color: rgba(255,180,100,0.4); display: block; margin-top: 2px; }
.grade-pill.active { border-color: #F5A623; background: rgba(245,166,35,0.18); color: #FFD580; }
.sidebar-input {
  width: 100%; padding: 9px 11px;
  border: 1.5px solid rgba(255,180,100,0.15); border-radius: 9px;
  background: rgba(255,255,255,0.06); color: rgba(255,240,220,0.9);
  font-size: 13px; font-family: inherit; outline: none; margin-top: 5px;
}
.sidebar-input:focus { border-color: #E8682A; }
.sidebar-input::placeholder { color: rgba(255,200,140,0.3); }
.sidebar-select {
  width: 100%; padding: 9px 11px;
  border: 1.5px solid rgba(255,180,100,0.15); border-radius: 9px;
  background: #2C1810; color: rgba(255,240,220,0.85);
  font-size: 13px; font-family: inherit; outline: none; margin-bottom: 7px; cursor: pointer;
}

/* ── Card (setup page white cards on warm bg) ── */
.card {
  background: #FFFFFF; border-radius: 16px; padding: 13px;
  margin-bottom: 8px; box-shadow: 0 2px 12px rgba(180,100,40,0.10);
  border: 1px solid #F0D9C0;
}
.card .label {
  font-size: 10px; color: #9A7A6A; font-weight: 800;
  margin-bottom: 9px; display: block; text-transform: uppercase; letter-spacing: 0.8px;
}

/* ── Setup header ── */
.setup-header { text-align: center; padding: 8px 0 6px; }
.setup-logo {
  font-size: 28px; font-weight: 900; letter-spacing: -1px; line-height: 1; margin-bottom: 2px;
  background: linear-gradient(135deg, #E8682A, #F5A623, #E84393);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.setup-tagline { font-size: 11px; color: #9A7A6A; font-weight: 600; }

/* ── Mode grid ── */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mode-card {
  border-radius: 12px; border: 2px solid #F0D9C0; background: #FFFFFF;
  padding: 10px 8px; cursor: pointer; text-align: center; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mode-card:hover { border-color: #E8682A; box-shadow: 0 2px 10px rgba(232,104,42,0.15); }
.mode-card.active { border-color: #1D9E75; background: #E6F7F1; }
.mode-card.coming-soon { opacity: 0.5; cursor: not-allowed; }
.mode-card.coming-soon::after {
  content: 'Coming soon'; position: absolute; top: 5px; right: 5px;
  background: #9A7A6A; color: #fff; font-size: 8px; font-weight: 700;
  padding: 2px 5px; border-radius: 6px;
}
.mode-icon { font-size: 22px; }
.mode-name { font-size: 12px; font-weight: 800; color: #2C1810; }
.mode-desc { font-size: 10px; color: #9A7A6A; line-height: 1.3; }

/* ── Subject chips ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; border-radius: 15px;
  border: 1.5px solid #F0D9C0; background: #FFF8F0;
  color: #4A3020; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: border-color 0.12s;
}
.chip:hover { border-color: #E8682A; color: #E8682A; }
.chip.active { border-color: #E8682A; background: #FFF0E6; color: #C04F18; }
.chip-desc { font-size: 11px; color: #9A7A6A; margin-top: 7px; padding: 7px 9px; background: #FFF8F0; border-radius: 8px; line-height: 1.5; }

/* ── World / Guide grids ── */
.world-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
@media(max-width:380px){.world-grid{grid-template-columns:repeat(2,1fr);}}
.world-card {
  border-radius: 12px; border: 2px solid #F0D9C0; background: #FFFFFF;
  text-align: center; padding: 5px 3px; cursor: pointer;
  transition: border-color 0.12s; position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.world-card:hover { border-color: #F5A623; }
.world-card.active { border-color: #F5A623; background: #FFF9EC; box-shadow: 0 0 10px rgba(245,166,35,0.2); }
.world-card svg { width: 100%; max-height: 64px; border-radius: 8px; overflow: hidden; }
.world-card-label { font-size: 10px; font-weight: 800; margin-top: 3px; color: #2C1810; }
.world-card .card-desc { font-size: 9px; color: #9A7A6A; margin-top: 1px; line-height: 1.3; display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.world-card .lore-btn {
  margin-top: 3px; background: none; border: 1px solid #F0D9C0;
  border-radius: 10px; padding: 1px 6px; font-size: 8px; color: #C4A898;
  cursor: pointer; font-weight: 700; font-family: inherit;
}
.active-check {
  position: absolute; top: 4px; right: 4px; background: #F5A623;
  color: #fff; border-radius: 50%; width: 15px; height: 15px;
  font-size: 8px; font-weight: 900; display: none; align-items: center; justify-content: center;
}
.world-card.active .active-check { display: flex; }

.guide-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.guide-card {
  border-radius: 12px; border: 2px solid #F0D9C0; background: #FFFFFF;
  text-align: center; padding: 5px 3px; cursor: pointer;
  transition: border-color 0.12s; position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.guide-card:hover { border-color: #F5A623; }
.guide-card.active { border-color: #F5A623; background: #FFF9EC; }
.guide-card svg { width: 100%; max-height: 72px; }
.guide-card-name { font-size: 10px; font-weight: 800; margin-top: 2px; color: #2C1810; }
.guide-card .card-desc { font-size: 9px; color: #9A7A6A; margin-top: 1px; line-height: 1.3; display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.guide-card .lore-btn {
  margin-top: 3px; background: none; border: 1px solid #F0D9C0;
  border-radius: 10px; padding: 1px 6px; font-size: 8px; color: #C4A898;
  cursor: pointer; font-weight: 700; font-family: inherit;
}
.guide-card .active-check { display: none; }
.guide-card.active .active-check { display: flex; }
.card-desc { font-size: 11px; color: #9A7A6A; line-height: 1.5; margin-top: 4px; text-align: center; }

/* ── Q count ── */
.q-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid #F0D9C0; background: #FFF8F0;
  font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #4A3020; font-family: inherit;
}
.q-btn:hover { border-color: #E8682A; color: #E8682A; }
.q-num { font-size: 20px; font-weight: 900; color: #2C1810; min-width: 26px; text-align: center; }

/* ── Action buttons ── */
.action-btn {
  width: 100%; padding: 13px;
  background: #E8682A; color: #fff; border: none; border-radius: 14px;
  font-size: 15px; font-weight: 800; cursor: pointer; margin-bottom: 7px;
  font-family: inherit; box-shadow: 0 4px 0 #C04F18;
  transition: transform 0.1s, box-shadow 0.1s;
}
.action-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #C04F18; }
.action-btn:hover { background: #F07830; }
.action-btn.sec { background: #FFFFFF; color: #4A3020; box-shadow: 0 4px 0 #F0D9C0; border: 1px solid #F0D9C0; }
.action-btn.sec:hover { background: #FFF4E8; }
.action-btn.share { background: #7C4DDB; box-shadow: 0 4px 0 #4A2AA0; }
.action-btn.share:hover { background: #8D5AE8; }

/* ── Error ── */
.err { background: #FEF0EF; border: 1.5px solid #F5B8B7; border-radius: 10px; padding: 9px 13px; font-size: 13px; color: #D64236; margin-bottom: 9px; display: none; font-weight: 600; }

/* ── Sidebar inputs (already styled above) ── */
.key-input {
  width: 100%; padding: 9px 11px;
  border: 1.5px solid rgba(255,180,100,0.15); border-radius: 9px;
  background: rgba(255,255,255,0.06); color: rgba(255,240,220,0.9);
  font-size: 13px; font-family: monospace; outline: none;
}
.key-input:focus { border-color: #E8682A; }

/* ── Progress bar (game screen) ── */
.pbar { height: 7px; background: #F0D9C0; border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.pfill { height: 100%; background: linear-gradient(90deg, #E8682A, #F5A623); border-radius: 4px; transition: width 0.4s ease; }

/* ── Star row ── */
.star-row { display: flex; gap: 2px; align-items: center; }

/* ── Guide bubble (game screen) ── */
.bubble {
  display: flex; gap: 9px; padding: 11px;
  background: #FFFFFF; border-radius: 14px;
  margin-bottom: 9px; box-shadow: 0 2px 10px rgba(180,80,20,0.1);
  border: 1px solid #F0D9C0;
}
.av {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #E8682A, #F5A623);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 900; color: #fff; flex-shrink: 0;
}
.av-name { font-size: 10px; color: #E8682A; font-weight: 800; margin-bottom: 2px; }
.av-text { font-size: 13px; color: #2C1810; line-height: 1.5; font-weight: 600; }

/* ── Battle arena (game screen — keep dark) ── */
.battle-arena {
  border-radius: 14px; background: linear-gradient(160deg, #200A02, #2E1000);
  margin-bottom: 9px; border: 1px solid rgba(255,140,60,0.12);
  display: flex; align-items: center; justify-content: space-around; padding: 12px 8px;
}
.vs-label { font-size: 13px; font-weight: 900; color: rgba(255,120,60,0.7); letter-spacing: 2px; }
.player-side, .monster-side { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.guide-avatar-battle, .monster-svg { width: 66px; height: 66px; }
.monster-name { font-size: 10px; font-weight: 800; color: rgba(255,220,170,0.7); text-transform: uppercase; }
.health-bar-wrap { width: 66px; height: 5px; background: rgba(255,180,100,0.15); border-radius: 3px; overflow: hidden; }
.health-bar { height: 100%; border-radius: 3px; transition: width 0.35s ease; }
.player-hp { background: linear-gradient(90deg, #E8682A, #F5A623); }
.monster-hp { background: linear-gradient(90deg, #D64236, #F07830); }

/* ── Question card (game screen — white on dark bg) ── */
.q-card { position: relative; }
.story-before {
  background: #FFF9F5; border-left: 3px solid #E8682A;
  border-radius: 0 9px 9px 0; padding: 9px 11px;
  font-size: 13px; color: #4A3020; line-height: 1.6; font-style: italic; margin-bottom: 9px;
}
.story-divider {
  display: flex; align-items: center; justify-content: center;
  margin: 9px 0; gap: 8px; font-size: 15px;
}
.story-divider::before,.story-divider::after { content:''; flex:1; height:1px; background:#F0D9C0; }
.q-text { font-size: 16px; font-weight: 800; color: #2C1810; line-height: 1.55; margin-bottom: 14px; }
.q-blank {
  display: inline-block; min-width: 52px; border-bottom: 2.5px solid #E8682A;
  text-align: center; color: transparent; padding: 0 7px; margin: 0 3px;
  vertical-align: baseline; position: relative; top: -1px;
}
.q-blank.filled { border-bottom: none; border-radius: 7px; color: #fff; font-weight: 800; padding: 2px 10px; top: 0; }
.q-blank.filled.right { background: #1D9E75; }
.q-blank.filled.wrong { background: #D64236; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed #F0C090; border-radius: 12px; padding: 16px;
  text-align: center; margin-bottom: 12px;
  background: #FFFAF5; min-height: 72px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, background-color 0.12s;
}
.drop-zone.over { border-color: #E8682A; background: #FFF0E6; }
.drop-zone.result-right { border-color: #1D9E75; background: #E6F7F1; }
.drop-zone.result-wrong { border-color: #D64236; background: #FEF0EF; }
.drop-zone-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #D4A070; font-size: 12px; font-weight: 700; }

/* ── Answer cards ── */
.cards-tray { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 5px; }
.answer-card {
  padding: 13px 9px; border-radius: 12px;
  border: 2px solid #F0D9C0; background: #FFFFFF;
  color: #2C1810; font-size: 13px; font-weight: 700;
  cursor: grab; text-align: center; line-height: 1.4;
  user-select: none; position: relative;
  box-shadow: 0 3px 0 #F0D9C0;
}
.answer-card:active { cursor: grabbing; }
.answer-card.is-placed { opacity: 0.38; cursor: not-allowed; }
.answer-card.is-locked { cursor: not-allowed; }
.answer-card.result-right { border-color: #1D9E75; background: #E6F7F1; box-shadow: 0 3px 0 #0d6b53; color: #0d4a2a; }
.answer-card.result-wrong { border-color: #D64236; background: #FEF0EF; box-shadow: 0 3px 0 #A02820; color: #5a0a06; }
.answer-card.result-reveal { border-color: #1D9E75; background: #E6F7F1; box-shadow: 0 3px 0 #0d6b53; }
.answer-card-label {
  position: absolute; top: -8px; left: 7px; width: 19px; height: 19px; border-radius: 50%;
  background: #E8682A; color: #fff; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

/* ── Dragging ghost ── */
.dragging-ghost {
  position: fixed; pointer-events: none; z-index: 9999;
  border-radius: 12px; padding: 12px 16px;
  background: linear-gradient(135deg, #E8682A, #F5A623);
  color: #fff; font-weight: 800; font-size: 13px;
  box-shadow: 0 8px 20px rgba(232,104,42,0.4);
  max-width: 170px; text-align: center; will-change: transform; transform: rotate(2deg);
}

/* ── Confirm / Next buttons ── */
.confirm-btn { background: #7C4DDB !important; box-shadow: 0 4px 0 #4A2AA0 !important; }
.confirm-btn:active { transform: translateY(3px) !important; box-shadow: 0 1px 0 #4A2AA0 !important; }
#btn-next { position: sticky; bottom: 14px; z-index: 10; box-shadow: 0 4px 16px rgba(232,104,42,0.3), 0 0 0 2px rgba(255,255,255,0.6); }

/* ── Feedback ── */
.fb {
  border-radius: 11px; padding: 11px 13px; margin-top: 11px;
  font-size: 13px; line-height: 1.6; font-weight: 700; display: none;
  border-left: 3px solid #1D9E75; background: #E6F7F1; color: #0d4a2a;
}
.fb.bad { border-left-color: #D64236; background: #FEF0EF; color: #5a0a06; }

/* ── Prologue screen ── */
.seed-box { background: #FFFFFF; border: 1px solid #F0D9C0; border-radius: 11px; padding: 11px; margin-bottom: 11px; text-align: center; box-shadow: 0 2px 8px rgba(180,100,40,0.08); }
.seed-id { font-size: 10px; color: #9A7A6A; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.seed-val { font-size: 19px; font-weight: 900; color: #2C1810; letter-spacing: 2px; }
.badge { display: inline-block; border-radius: 7px; padding: 2px 8px; font-size: 11px; font-weight: 800; }
.bt { background: #FFF0E6; color: #C04F18; }
.bp { background: #FFF9EC; color: #8A5C10; }
.bb { background: #F3EDFF; color: #5A2FAA; }
.subtopic-tag { display: inline-block; padding: 2px 7px; border-radius: 7px; font-size: 11px; font-weight: 800; margin-left: 5px; background: #FFF0E6; color: #C04F18; }

/* ── Loading ── */
.dots { display: flex; gap: 7px; justify-content: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #E8682A; animation: bounce 1.2s infinite; }
.dot:nth-child(2){animation-delay:.2s;} .dot:nth-child(3){animation-delay:.4s;}
@keyframes bounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-10px)}}

/* ── Result screen ── */
.lb-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid #F0D9C0; font-size: 13px; color: #4A3020; }
.lb-row:last-child { border-bottom: none; }
.lb-rank { font-weight: 900; color: #9A7A6A; width: 20px; }
.lb-name { flex: 1; font-weight: 700; color: #2C1810; }
.lb-score { font-weight: 800; color: #E8682A; }

/* ── Game top bar ── */
#g-home-btn {
  background: #FFFFFF; border: 1px solid #F0D9C0;
  border-radius: 16px; padding: 5px 11px; font-size: 12px;
  color: #4A3020; cursor: pointer; font-weight: 700; font-family: inherit;
  box-shadow: 0 2px 6px rgba(180,100,40,0.08);
}
#g-home-btn:hover { background: #FFF4E8; }

/* ── Modals ── */
.copy-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2C1810; color: #fff; padding: 9px 18px; border-radius: 18px; font-size: 13px; font-weight: 700; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.copy-toast.show { opacity: 1; }
.modal-overlay { position: fixed; inset: 0; background: rgba(44,24,16,0.5); z-index: 9000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal-box { background: #FFFFFF; border-radius: 18px; padding: 22px; width: min(340px,92vw); }
.modal-title { font-size: 17px; font-weight: 800; color: #2C1810; margin-bottom: 5px; }
.modal-sub { font-size: 12px; color: #9A7A6A; margin-bottom: 12px; }
.name-input { width: 100%; padding: 11px; border: 2px solid #F0D9C0; border-radius: 9px; font-size: 14px; font-family: inherit; outline: none; color: #2C1810; }
.name-input:focus { border-color: #E8682A; }

/* ── Particles ── */
#particle-container { position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden; }

/* ── Battle animations ── */
@keyframes hitShake{0%,100%{transform:translateX(0)}25%{transform:translateX(-5px)}75%{transform:translateX(5px)}}
.battle-guide-avatar.hit,.monster-svg.hit{animation:hitShake 0.35s ease;}

/* ── Lore modal ── */
#lore-modal { display: none; position: fixed; inset: 0; background: rgba(44,24,16,0.6); z-index: 9200; align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto; }
#lore-box { background: #FFFFFF; border-radius: 20px; width: min(500px,96vw); box-shadow: 0 20px 60px rgba(44,24,16,0.3); margin: auto; }
#lore-body { padding: 14px 18px 24px; font-size: 13px; color: #4A3020; line-height: 1.8; white-space: pre-line; }

/* ── Millionaire ── */
.mm-hud-bar { display: flex; justify-content: space-between; align-items: center; background: #FFFFFF; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(180,100,40,0.12); border: 1px solid #F0D9C0; min-height: 56px; }
.mm-diamonds { font-size: 22px; font-weight: 900; color: #1D9E75; line-height: 1.3; }
.mm-diamonds-label { font-size: 9px; color: #9A7A6A; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.mm-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.mm-tool-btn { flex: 1; min-width: 130px; padding: 8px 9px; border-radius: 9px; border: 1.5px solid #F0C090; background: #FFF0E6; color: #C04F18; font-size: 12px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-family: inherit; }
.mm-tool-btn:hover:not([disabled]) { background: #FFE5CC; }
.mm-tool-btn[disabled],.mm-tool-btn.locked { opacity: 0.38; cursor: not-allowed; }
.mm-tool-row { display: flex; align-items: center; gap: 5px; }
.mm-tool-count { background: #E8682A; color: #fff; font-size: 9px; font-weight: 900; width: 15px; height: 15px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-left: auto; }
.mm-tool-desc { font-size: 10px; color: #E8682A; opacity: 0.8; }
.mm-ladder { overflow-x: auto; margin-bottom: 9px; }
.mm-ladder-inner { display: flex; gap: 4px; min-width: max-content; padding: 2px 0; }
.mm-step { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 6px; border-radius: 7px; min-width: 45px; border: 1.5px solid #F0D9C0; background: #FFF8F0; font-size: 10px; font-weight: 700; color: #9A7A6A; flex-shrink: 0; }
.mm-step .step-val { font-size: 10px; font-weight: 800; }
.mm-step .step-num { font-size: 8px; color: #C4A898; margin-top: 1px; }
.step-safe-badge { font-size: 7px; display: block; margin-top: 1px; }
.mm-step.step-safe { border-color: #1D9E75; color: #0d6b53; background: #E6F7F1; }
.mm-step.step-active { border-color: #F5A623; background: #FFF9EC; color: #8A5C10; transform: scale(1.06); box-shadow: 0 2px 8px rgba(245,166,35,0.25); }
.mm-step.step-passed { background: #E6F7F1; border-color: #A7F3D0; color: #0d6b53; opacity: 0.75; }
.safe-hint-box { background: #E6F7F1; border: 1.5px solid #6EE7B7; border-radius: 9px; padding: 9px 11px; margin-bottom: 9px; font-size: 12px; color: #0d6b53; display: none; align-items: flex-start; gap: 7px; }
.safe-hint-box.show { display: flex; }
.mm-decision { position: absolute; inset: 0; background: rgba(255,255,255,0.97); border-radius: 16px; display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 50; padding: 18px; text-align: center; }
.mm-decision.show { display: flex; }
.mm-dec-title { font-size: 17px; font-weight: 800; color: #1D9E75; margin-bottom: 3px; }
.mm-dec-diamonds { font-size: 36px; font-weight: 900; color: #1D9E75; margin: 7px 0; }
.mm-dec-warning { background: #FFF9EC; border: 1px solid #F5D080; border-radius: 8px; padding: 7px 11px; font-size: 12px; color: #8A5C10; margin-bottom: 12px; line-height: 1.5; max-width: 280px; }
.mm-dec-actions { display: flex; gap: 7px; width: 100%; max-width: 280px; }
.mm-dec-keep { flex: 1; padding: 11px; border-radius: 9px; background: #FFF4E8; color: #4A3020; border: 1px solid #F0D9C0; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.mm-dec-next { flex: 1; padding: 11px; border-radius: 9px; background: #1D9E75; color: #fff; border: none; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; box-shadow: 0 3px 0 #0d6b53; }

/* ── Rogue ── */
.rg-hud-bar { background: #FFFFFF; border: 1px solid #F0D9C0; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(180,100,40,0.12); min-height: 56px; }
.rg-stats { display: flex; align-items: center; gap: 14px; }
.rg-stat-label { font-size: 10px; color: #9A7A6A; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.rg-stat-val { font-size: 22px; font-weight: 900; line-height: 1.3; }
.rg-stat-val.hp { color: #D64236; }
.rg-stat-val.supply { color: #F5A623; }
.rg-stage-label { font-size: 12px; font-weight: 800; color: #E8682A; }
.rg-dots { display: flex; gap: 3px; margin-top: 4px; justify-content: flex-end; }
.rg-dot { width: 12px; height: 4px; background: #F0D9C0; border-radius: 2px; }
.rg-dot.active { background: #E8682A; }
.rg-explore-section { margin-bottom: 11px; }
.rg-paths-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.rg-path-card { background: #FFFFFF; border: 2px solid #F0D9C0; border-radius: 13px; padding: 12px 10px; cursor: pointer; transition: border-color 0.15s; display: flex; flex-direction: column; gap: 5px; }
.rg-path-card:hover { border-color: #E8682A; }
.rg-risk-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 14px; align-self: flex-start; }
.rg-risk-high { background: #FEF0EF; color: #D64236; }
.rg-risk-low  { background: #E6F7F1; color: #0d6b53; }
.rg-path-subject { font-size: 9px; color: #9A7A6A; font-weight: 700; }
.rg-path-name { font-size: 14px; font-weight: 800; color: #2C1810; }
.rg-path-desc { font-size: 11px; color: #9A7A6A; line-height: 1.4; flex: 1; }
.rg-reward-row { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 700; border-top: 1px solid #F0D9C0; padding-top: 7px; }
.rg-win-text  { color: #1D9E75; }
.rg-lose-text { color: #D64236; }
@keyframes rgPop{0%,100%{transform:scale(1)}40%{transform:scale(1.3)}}
.rg-pop { animation: rgPop 0.3s ease; }

/* ── Grid ── */
.gr-hud-bar { display: flex; justify-content: space-between; align-items: center; background: #FFFFFF; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(180,100,40,0.12); border: 1px solid #F0D9C0; min-height: 56px; }
.gr-hp { font-size: 24px; letter-spacing: 2px; line-height: 1.3; }
.gr-score { font-size: 20px; font-weight: 900; color: #E8682A; }
.gr-score-label { font-size: 10px; color: #9A7A6A; font-weight: 800; text-transform: uppercase; margin-bottom: 4px; letter-spacing: 0.5px; }
.gr-board-wrap { margin-bottom: 11px; }
.gr-board-title { font-size: 12px; font-weight: 800; color: #9A7A6A; margin-bottom: 7px; text-align: center; }
.gr-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.gr-tile { background: #FFFFFF; border: 2px solid #F0D9C0; border-radius: 13px; padding: 13px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; transition: border-color 0.15s; min-height: 76px; font-family: inherit; }
.gr-tile:hover:not([disabled]) { border-color: #E8682A; }
.gr-tile[disabled] { cursor: default; }
.gr-tile-icon { font-size: 20px; }
.gr-tile-label { font-size: 9px; font-weight: 700; color: #9A7A6A; text-align: center; line-height: 1.3; }
.gr-empty  { background: #FFFFFF; }
.gr-won    { background: #E6F7F1; border-color: #1D9E75 !important; }
.gr-lost   { background: #FEF0EF; border-color: #D64236 !important; opacity: 0.7; }
.gr-win-flash { border-color: #F5A623 !important; box-shadow: 0 0 10px rgba(245,166,35,0.35); }
@keyframes grWinPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.07)}}
.gr-win-flash{animation:grWinPulse 0.5s ease 0.1s;}

/* ── Misc ── */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sep { border: none; border-top: 1px solid #F0D9C0; margin: 12px 0; }

/* ── Topic picker (roguelike) ── */
#rogue-topic-card { border: 1px solid #F0D9C0; }

/* ── Auth modal ── */
#auth-modal > div { background: #FFFFFF; }
#profile-modal > div { background: #FFFFFF; }

/* ── World customize textarea ── */
#world-custom-input:focus { border-color: #E8682A !important; background: #FFFFFF !important; }
#world-custom-input::placeholder { color: #C4A898; }
#world-custom-input:disabled { background: #F5F0E8 !important; color: #C4A898; cursor: not-allowed; }

/* ==========================================
   Discover Feed
   ========================================== */
.disc-nav-btn {
  background: #FFFFFF; border: 1.5px solid #F0D9C0;
  border-radius: 20px; padding: 6px 16px;
  font-size: 13px; font-weight: 700; color: #4A3020;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 6px rgba(180,100,40,0.08);
}
.disc-nav-btn:hover { border-color: #E8682A; color: #E8682A; }

.discover-card {
  background: #FFFFFF; border-radius: 18px;
  border: 1.5px solid #F0D9C0;
  box-shadow: 0 4px 20px rgba(180,100,40,0.12);
  overflow: hidden;
}
.discover-card-art {
  width: 100%; max-height: 160px; overflow: hidden;
  background: linear-gradient(135deg, #FFF0E6, #FFF9EC);
  display: flex; align-items: center; justify-content: center;
}
.discover-card-art svg { width: 100%; max-height: 160px; }
.discover-card-body { padding: 16px 16px 0; }
.discover-mode-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #FFF0E6; color: #C04F18;
  font-size: 11px; font-weight: 800;
  border-radius: 20px; padding: 3px 10px; margin-bottom: 10px;
}
.discover-quest-arc {
  font-size: 15px; font-weight: 700; color: #2C1810;
  line-height: 1.5; margin-bottom: 10px;
  font-style: italic;
}
.discover-meta-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #9A7A6A; font-weight: 600;
  flex-wrap: wrap;
}
.discover-guide-chip {
  display: flex; align-items: center; gap: 4px;
  background: #FFF9EC; border-radius: 12px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; color: #8A5C10;
}
.discover-guide-chip svg { width: 18px; height: 18px; }

/* ── Horizontal scroll grids (mode / world / guide) ── */
.mode-grid-scroll, .world-grid-scroll, .guide-grid-scroll {
  display: flex;
  overflow-x: auto;
  gap: 9px;
  padding-bottom: 8px;
  padding-right: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #F0D9C0 transparent;
}
.mode-grid-scroll::-webkit-scrollbar,
.world-grid-scroll::-webkit-scrollbar,
.guide-grid-scroll::-webkit-scrollbar {
  height: 4px;
}
.mode-grid-scroll::-webkit-scrollbar-thumb,
.world-grid-scroll::-webkit-scrollbar-thumb,
.guide-grid-scroll::-webkit-scrollbar-thumb {
  background: #F0D9C0; border-radius: 2px;
}

/* Each item: fixed width + snap */
.mode-grid-scroll .mode-card {
  flex: 0 0 148px; scroll-snap-align: start;
  min-width: 148px;
}
.world-grid-scroll .world-card,
.guide-grid-scroll .guide-card {
  flex: 0 0 105px; scroll-snap-align: start;
  min-width: 105px;
}

/* Scroll hint arrow on right edge */
.scroll-hint {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px; color: #C4A898; pointer-events: none;
  animation: scrollPulse 1.5s ease-in-out infinite;
}
@keyframes scrollPulse { 0%,100%{opacity:.4} 50%{opacity:1} }

/* ==========================================
   Discover Catalog
   ========================================== */

/* Filter chips */
.disc-chip {
  padding: 5px 11px; border-radius: 16px;
  border: 1.5px solid #F0D9C0; background: #FFFFFF;
  color: #9A7A6A; font-size: 11px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  white-space: nowrap;
}
.disc-chip:hover  { border-color: #E8682A; color: #E8682A; }
.disc-chip.active { border-color: #E8682A; background: #FFF0E6; color: #C04F18; }

/* Card grid */
.discover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 380px) { .discover-grid { grid-template-columns: 1fr; } }

/* Catalog card */
.disc-card {
  background: #FFFFFF;
  border: 1.5px solid #F0D9C0;
  border-radius: 14px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 2px 8px rgba(180,100,40,0.07);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.disc-card:hover { border-color: #E8682A; box-shadow: 0 4px 14px rgba(232,104,42,0.12); }

.disc-card-mode {
  font-size: 10px; font-weight: 800;
  color: #C04F18; background: #FFF0E6;
  border-radius: 10px; padding: 2px 8px;
  align-self: flex-start;
}
.disc-card-arc {
  font-size: 12px; font-weight: 600; color: #2C1810;
  line-height: 1.45; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.disc-card-meta {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: #9A7A6A; font-weight: 600;
  flex-wrap: wrap;
}
.disc-card-play {
  width: 100%; padding: 8px;
  background: #E8682A; color: #fff;
  border: none; border-radius: 9px;
  font-size: 12px; font-weight: 800;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 3px 0 #C04F18;
  transition: transform 0.1s, box-shadow 0.1s;
  margin-top: 2px;
}
.disc-card-play:active { transform: translateY(2px); box-shadow: 0 1px 0 #C04F18; }

/* ── Discover sticky filter bar ── */
.disc-sticky-bar {
  position: sticky;
  top: 52px;           /* below the top-bar */
  z-index: 40;
  background: #FFF8F0;
  border-bottom: 1px solid #F0D9C0;
  padding: 10px 14px 8px;
  box-shadow: 0 2px 8px rgba(180,100,40,0.06);
}
/* Hide horizontal scrollbar on chip rows inside sticky bar */
.disc-sticky-bar div::-webkit-scrollbar { display: none; }

/* Played badge on catalog cards */
.disc-card-played {
  font-size: 10px; font-weight: 800;
  color: #0d6b53; background: #E6F7F1;
  border-radius: 8px; padding: 3px 8px;
  border: 1px solid #6EE7B7;
}
.disc-card-played-border {
  border-color: #6EE7B7 !important;
}

/* ==========================================
   Boss Rush Mode
   ========================================== */
.br-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; border: 1px solid #F0D9C0;
  box-shadow: 0 2px 10px rgba(180,100,40,0.10);
}
.br-stage-label { font-size: 10px; font-weight: 800; color: #9A7A6A; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 3px; }
.br-boss-name   { font-size: 17px; font-weight: 900; color: #2C1810; }
.br-hp-wrap     { text-align: right; }
.br-hp-pips     { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; max-width: 160px; }
.br-hp-pip      { width: 14px; height: 14px; border-radius: 50%; background: #F0D9C0; border: 1.5px solid #E0C4A8; }
.br-hp-pip-full { background: linear-gradient(135deg, #E8682A, #F5A623); border-color: #C04F18; box-shadow: 0 1px 4px rgba(232,104,42,0.35); }

.br-taunt {
  font-size: 12px; color: #9A7A6A; font-style: italic;
  text-align: center; padding: 6px 12px; margin-bottom: 8px;
  background: #FFF8F0; border-radius: 8px; line-height: 1.5;
  min-height: 20px;
}

.br-crit-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.br-crit-label { font-size: 10px; font-weight: 800; color: #E8682A; white-space: nowrap; min-width: 80px; }
.br-crit-track { flex: 1; height: 6px; background: #F0D9C0; border-radius: 3px; overflow: hidden; }
.br-crit-bar   { height: 100%; width: 100%; border-radius: 3px; transition: width 0.1s linear, background 0.3s; }

/* Crit flash */
.br-crit-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 250;
  background: radial-gradient(circle, rgba(232,104,42,0.3) 0%, transparent 70%);
  opacity: 0;
}
.br-crit-flash.br-crit-active {
  animation: brFlash 0.5s ease-out;
}
@keyframes brFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Boss intro / defeat bounce */
@keyframes brBounce {
  0%,100% { transform: scale(1); }
  40%     { transform: scale(1.25) rotate(-5deg); }
  70%     { transform: scale(0.95) rotate(3deg); }
}
