/* ============================================================
   Adventure Quiz — Malaysia & Borneo
   Style sheet
   ============================================================ */

/* ── Custom properties ─────────────────────────────────────── */
:root {
  --bg:          #0d1b2a;
  --bg-card:     #142030;
  --bg-card2:    #1a2e44;
  --border:      #1e3a54;
  --teal:        #00d4aa;
  --teal-dim:    #00a880;
  --orange:      #ff7f3f;
  --orange-dim:  #d96030;
  --yellow:      #ffd60a;
  --success:     #3ddc84;
  --error:       #ff5252;
  --text:        #e8f4f8;
  --text-muted:  #6b8fa8;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 8px 32px rgba(0,0,0,.45);
  --transition:  .2s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input  { color: inherit; font: inherit; }

/* ── App shell ──────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Header ─────────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
#header.hidden { display: none; }
.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 10px; }
#header-player-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
#header-player-btn:hover { background: var(--bg-card2); }
#header-avatar { font-size: 1.4rem; }
#header-name   { font-weight: 600; font-size: .95rem; }

.score-pill {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .9rem;
  font-weight: 700;
  color: var(--yellow);
}
.btn-icon {
  font-size: 1.4rem;
  padding: 4px;
  border-radius: 8px;
  transition: transform var(--transition);
}
.btn-icon:hover { transform: scale(1.15); }

/* ── Screens ─────────────────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn .25s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ══════════════════════════════════════════════════════════════
   PROFILE SCREEN
══════════════════════════════════════════════════════════════ */
.profile-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 28px;
}
.logo-block { text-align: center; }
.logo-palm {
  font-size: 4rem;
  animation: sway 3s ease-in-out infinite;
  display: block;
}
@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50%       { transform: rotate(4deg);  }
}
.game-title    { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; }
.game-subtitle { color: var(--teal); font-size: 1rem; margin-top: 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; color: var(--text-muted); font-weight: 600; }

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.avatar-btn {
  font-size: 2rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  background: var(--bg-card2);
}
.avatar-btn:hover  { border-color: var(--teal); transform: scale(1.1); }
.avatar-btn.chosen { border-color: var(--teal); background: rgba(0,212,170,.15); box-shadow: 0 0 0 3px rgba(0,212,170,.25); }

.text-input {
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  width: 100%;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.text-input:focus { border-color: var(--teal); }
.text-input::placeholder { color: var(--text-muted); }

.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-list-label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.saved-player-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-align: left;
}
.saved-player-btn:hover { border-color: var(--teal); background: rgba(0,212,170,.08); }
.saved-player-emoji { font-size: 1.4rem; }
.saved-player-info  { flex: 1; }
.saved-player-name  { font-weight: 600; font-size: .95rem; }
.saved-player-sub   { font-size: .8rem; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   MAIN MENU
══════════════════════════════════════════════════════════════ */
.menu-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
}

.map-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.map-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.map-dot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: .35;
  transition: opacity var(--transition);
}
.map-dot.active  { opacity: 1; }
.map-dot.unlocked { opacity: .75; }
.map-dot span    { font-size: 1.6rem; }
.map-dot small   { font-size: .7rem; color: var(--text-muted); white-space: nowrap; }
.map-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  position: relative; bottom: 10px;
}

.modes-grid { display: flex; flex-direction: column; gap: 12px; }

.mode-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.mode-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,212,170,.06), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.mode-card:hover       { border-color: var(--teal); transform: translateY(-2px); box-shadow: var(--shadow); }
.mode-card:hover::before { opacity: 1; }
.mode-card:active      { transform: scale(.98); }
.mode-card.mode-speed  { border-color: rgba(255,127,63,.4); }
.mode-card.mode-speed:hover { border-color: var(--orange); }

.mode-icon { font-size: 2.2rem; flex-shrink: 0; }
.mode-body { flex: 1; }
.mode-body h3 { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.mode-body p  { font-size: .82rem; color: var(--text-muted); }
.mode-arrow   { font-size: 1.4rem; color: var(--text-muted); }

.badge-strip { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding-bottom: 8px; }
.badge-mini {
  font-size: 1.4rem;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
}
.badge-mini.earned {
  border-color: var(--yellow);
  background: rgba(255,214,10,.1);
  box-shadow: 0 0 10px rgba(255,214,10,.2);
}

/* ══════════════════════════════════════════════════════════════
   SHARED GAME CHROME
══════════════════════════════════════════════════════════════ */
.game-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
}
.game-topbar {
  display: flex; align-items: center; gap: 10px;
  height: 40px;
}
.topbar-title { flex: 1; font-size: 1rem; font-weight: 700; text-align: center; }
.topbar-score {
  font-size: .85rem; font-weight: 700;
  color: var(--yellow);
  min-width: 40px; text-align: right;
}

.btn-back {
  font-size: .85rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-back:hover { border-color: var(--teal); color: var(--teal); }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-dim));
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Feedback panel ──────────────────────────────────────────── */
.feedback-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: slideUp .25s ease;
}
.feedback-panel.hidden { display: none; }
@keyframes slideUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

.fb-icon   { font-size: 2.8rem; }
.fb-result { font-size: 1.1rem; font-weight: 700; }
.fb-result.correct { color: var(--success); }
.fb-result.wrong   { color: var(--error);   }

.fun-fact {
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.55;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
}
.fun-fact strong { color: var(--teal); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dim));
  color: #000;
  font-weight: 700; font-size: 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-align: center;
}
.btn-primary:hover  { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: scale(.98); }

.btn-ghost {
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

/* ══════════════════════════════════════════════════════════════
   SPOT THE ANIMAL
══════════════════════════════════════════════════════════════ */
.animal-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  transition: border-color .2s;
}
.animal-card.correct-glow { border-color: var(--success); box-shadow: 0 0 24px rgba(61,220,132,.25); }
.animal-card.wrong-glow   { border-color: var(--error);   box-shadow: 0 0 24px rgba(255,82,82,.25);  }

.animal-emoji {
  font-size: 6rem;
  line-height: 1;
  animation: popIn .3s cubic-bezier(.17,.67,.35,1.3);
}
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.animal-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.animal-statement {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.btn-answer {
  padding: 16px 10px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid transparent;
  transition: all var(--transition);
}
.btn-correct {
  background: rgba(61,220,132,.12);
  border-color: rgba(61,220,132,.4);
  color: var(--success);
}
.btn-correct:hover { background: rgba(61,220,132,.22); border-color: var(--success); transform: translateY(-2px); }
.btn-wrong {
  background: rgba(255,82,82,.12);
  border-color: rgba(255,82,82,.4);
  color: var(--error);
}
.btn-wrong:hover { background: rgba(255,82,82,.22); border-color: var(--error); transform: translateY(-2px); }

/* ══════════════════════════════════════════════════════════════
   EXPLORE MALAYSIA — question card
══════════════════════════════════════════════════════════════ */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.q-num  { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.q-text { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }

.opts-grid { display: flex; flex-direction: column; gap: 10px; }
.opt-btn {
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: all var(--transition);
  position: relative;
}
.opt-btn:hover:not(:disabled) { border-color: var(--teal); background: rgba(0,212,170,.08); }
.opt-btn:active:not(:disabled){ transform: scale(.98); }
.opt-btn.correct-opt { border-color: var(--success); background: rgba(61,220,132,.15); color: var(--success); font-weight: 700; }
.opt-btn.wrong-opt   { border-color: var(--error);   background: rgba(255,82,82,.12);  color: var(--error); }
.opt-btn:disabled    { cursor: default; }

/* ══════════════════════════════════════════════════════════════
   MATCH & MEMORY
══════════════════════════════════════════════════════════════ */
.match-hint {
  font-size: .85rem;
  color: var(--text-muted);
  text-align: center;
}
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.match-tile {
  padding: 14px 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.match-tile:hover:not(.matched):not(.selected) { border-color: var(--teal); background: rgba(0,212,170,.08); }
.match-tile.selected { border-color: var(--orange); background: rgba(255,127,63,.12); box-shadow: 0 0 0 2px rgba(255,127,63,.3); }
.match-tile.matched  { border-color: var(--success); background: rgba(61,220,132,.12); color: var(--success); cursor: default; opacity: .7; }
.match-tile.shake    { animation: shake .35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* ══════════════════════════════════════════════════════════════
   SPEED ROUND
══════════════════════════════════════════════════════════════ */
.speed-wrap { padding: 16px; gap: 14px; }

.speed-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}
.timer-ring {
  position: relative;
  width: 70px; height: 70px;
  flex-shrink: 0;
}
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: var(--bg-card2); stroke-width: 5; }
.ring-fill { fill: none; stroke: var(--teal); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .9s linear, stroke .5s; }
.ring-fill.urgent { stroke: var(--error); }
#speed-timer {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800;
}
.speed-info  { display: flex; flex-direction: column; gap: 4px; }
.speed-stat  { font-size: .85rem; color: var(--text-muted); }
.speed-stat strong { color: var(--text); font-size: 1.1rem; }

.speed-qcard { flex: 1; }
.speed-opts  { display: flex; flex-direction: column; gap: 10px; }

.opt-btn.flash-correct { animation: flashGreen .4s ease; }
.opt-btn.flash-wrong   { animation: flashRed   .4s ease; }
@keyframes flashGreen { 0%,100%{background:var(--bg-card2);} 50%{background:rgba(61,220,132,.35);} }
@keyframes flashRed   { 0%,100%{background:var(--bg-card2);} 50%{background:rgba(255,82,82,.35);} }

/* ══════════════════════════════════════════════════════════════
   SPEED RESULTS
══════════════════════════════════════════════════════════════ */
.results-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 20px;
  text-align: center;
}
.results-trophy { font-size: 4rem; animation: bounce .6s ease; }
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  40%     { transform: translateY(-16px); }
  60%     { transform: translateY(-8px); }
}
.results-wrap h2 { font-size: 1.5rem; font-weight: 800; }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
}
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--teal); }
.stat-lbl { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.new-badges {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
}
.new-badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(255,214,10,.08);
  border: 1.5px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  animation: popIn .4s ease;
}
.new-badge-icon { font-size: 1.8rem; }
.new-badge-name { font-size: .8rem; font-weight: 700; color: var(--yellow); }

/* ══════════════════════════════════════════════════════════════
   ACHIEVEMENTS OVERLAY
══════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end;
  animation: fadeIn .2s ease;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 80dvh;
  display: flex; flex-direction: column;
  padding: 20px;
  gap: 16px;
  overflow: hidden;
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
}
.overlay-head h2 { font-size: 1.2rem; font-weight: 800; }
.btn-close {
  font-size: 1.2rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-card2);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-close:hover { background: var(--border); }

.achievements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: 4px;
}
.ach-card {
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color var(--transition);
}
.ach-card.earned {
  border-color: var(--yellow);
  background: rgba(255,214,10,.06);
}
.ach-icon { font-size: 1.8rem; }
.ach-name { font-size: .85rem; font-weight: 700; }
.ach-desc { font-size: .75rem; color: var(--text-muted); line-height: 1.4; }
.ach-card:not(.earned) .ach-icon,
.ach-card:not(.earned) .ach-name { opacity: .4; filter: grayscale(1); }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 22px;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 200;
  white-space: nowrap;
  animation: toastIn .3s ease;
  pointer-events: none;
}
.toast.hidden { display: none; }
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ── Language toggle ─────────────────────────────────────────── */
.lang-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-toggle-profile {
  margin-top: 10px;
  justify-content: center;
}
.lang-btn {
  padding: 4px 10px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: none;
  transition: all var(--transition);
  letter-spacing: .04em;
}
.lang-btn:hover { color: var(--text); background: var(--bg-card2); }
.lang-btn.active { background: var(--teal); color: #000; }

/* ── Utilities ────────────────────────────────────────────────── */
.hidden { display: none !important; }
