:root {
  --green-dark: #1A3C2B;
  --green-mid: #3B6D11;
  --green-light: #EAF3DE;
  --amber: #F5A623;
  --amber-bg: #FAEEDA;
  --amber-text: #854F0B;
  --red: #A32D2D;
  --red-bg: #FCEBEB;
  --white: #ffffff;
  --bg: #f7f7f5;
  --bg-card: #ffffff;
  --border: rgba(0,0,0,0.1);
  --text: #1a1a1a;
  --text-muted: #666;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.app-screen { display: none; padding: 0 1rem 2rem; }
.app-screen.active { display: block; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-ball { font-size: 48px; margin-bottom: 0.5rem; }
.login-logo h1 { font-size: 28px; font-weight: 600; color: var(--green-dark); }
.login-region { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  padding: 1.75rem;
}
.login-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 1.25rem; line-height: 1.5; }
.login-help { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 1rem; }
.login-help a { color: var(--green-dark); }

.field-group { margin-bottom: 1rem; }
.field-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: 6px; }
.field-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.field-group input:focus { border-color: var(--green-dark); }

.code-inputs { display: flex; gap: 8px; margin-bottom: 1rem; justify-content: center; }
.code-digit {
  width: 44px; height: 52px;
  text-align: center;
  font-size: 22px; font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}
.code-digit:focus { border-color: var(--green-dark); }

.error-msg { background: var(--red-bg); border: 0.5px solid var(--red); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; color: var(--red); margin-bottom: 1rem; }
.hidden { display: none; }

/* ── NAV ── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--bg-card);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav-left { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.nav-ball-sm { font-size: 22px; }
.nav-title { font-size: 14px; font-weight: 600; color: var(--green-dark); }
.nav-sub { font-size: 10px; color: var(--text-muted); }
.nav-right { display: flex; align-items: center; gap: 8px; }
.pts-pill { font-size: 11px; color: var(--amber-text); background: var(--amber-bg); padding: 4px 10px; border-radius: 12px; font-weight: 500; }
.nav-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green-dark); color: var(--amber); font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ── PITCH TRACKER ── */
.pitch-track { background: var(--green-dark); border-radius: var(--radius); padding: 1rem 1.125rem; margin: 1rem 0 1.25rem; }
.pt-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.pt-label { font-size: 9px; color: rgba(255,255,255,0.5); letter-spacing: 0.07em; }
.pt-pct { font-size: 12px; color: var(--amber); font-weight: 600; }
.pitch-field { position: relative; height: 46px; background: #1F4A33; border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); overflow: hidden; }
.pf-goal-l { position: absolute; left: 0; top: 25%; width: 6px; height: 50%; border: 1px solid rgba(255,255,255,0.2); border-left: none; }
.pf-goal-r { position: absolute; right: 0; top: 25%; width: 6px; height: 50%; border: 1px solid rgba(255,255,255,0.2); border-right: none; }
.pf-center { position: absolute; left: 50%; top: 0; width: 1px; height: 100%; background: rgba(255,255,255,0.1); }
.pf-circle { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1); transform: translate(-50%,-50%); }
.pf-fill { position: absolute; left: 0; top: 0; height: 100%; background: rgba(245,166,35,0.15); border-right: 2px solid var(--amber); transition: width 0.8s ease; }
.pf-player { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14px; transition: left 0.8s ease; }
.pt-stages { display: flex; justify-content: space-between; margin-top: 6px; }
.pt-stage { font-size: 9px; color: rgba(255,255,255,0.3); }
.pt-stage.done { color: rgba(255,255,255,0.6); }
.pt-stage.active { color: var(--amber); font-weight: 600; }

/* ── SECTION LABEL ── */
.sec-label { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.07em; margin-bottom: 0.75rem; }

/* ── MODULE GRID ── */
.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.25rem; }
.mod-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s;
}
.mod-card:active:not(.locked) { transform: scale(0.98); }
.mod-card.locked { opacity: 0.5; cursor: not-allowed; }
.mod-card.active-mod { border-color: var(--green-dark); border-width: 1.5px; }
.mod-card.done-mod { border-color: var(--green-mid); }
.mod-num { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.mod-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 8px; }
.mod-chips { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { font-size: 9px; padding: 2px 6px; border-radius: 8px; background: var(--bg); color: var(--text-muted); border: 0.5px solid var(--border); }
.mod-foot { display: flex; align-items: center; justify-content: space-between; }
.mod-status { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.sdot { width: 6px; height: 6px; border-radius: 50%; }
.sdot.done { background: var(--green-mid); }
.sdot.active { background: var(--amber); }
.sdot.locked { background: var(--text-muted); opacity: 0.3; }
.stext.done { color: var(--green-mid); }
.stext.active { color: var(--amber-text); }
.stext.locked { color: var(--text-muted); }
.mod-bar { position: absolute; bottom: 0; left: 0; height: 2.5px; transition: width 0.5s; }
.mod-bar.done { background: var(--green-mid); }
.mod-bar.active { background: var(--amber); }
.lock-icon { position: absolute; top: 8px; right: 8px; font-size: 12px; opacity: 0.3; }

/* ── BADGES ── */
.badge-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 1.5rem; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 58px; }
.badge-circle { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.badge-circle.earned { background: var(--amber-bg); border: 1.5px solid var(--amber); }
.badge-circle.locked { background: var(--bg); border: 0.5px solid var(--border); opacity: 0.4; }
.badge-name { font-size: 9px; color: var(--text-muted); text-align: center; line-height: 1.2; }
.badge-name.earned { color: var(--amber-text); font-weight: 600; }

/* ── MODULE DETAIL ── */
.btn-back { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 1rem 0 0.75rem; }
.btn-back:active { color: var(--text); }
.mod-detail-header { display: flex; gap: 12px; margin-bottom: 1.25rem; }
.mod-detail-icon { width: 48px; height: 48px; background: var(--green-light); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.mod-detail-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.mod-detail-sub { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.mod-badge-earn { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; background: var(--green-light); border: 0.5px solid #97C459; border-radius: 10px; padding: 3px 8px; font-size: 11px; color: var(--green-mid); }
.mod-prog-row { display: flex; align-items: center; gap: 10px; margin-bottom: 1.25rem; }
.mpb { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.mpb-fill { height: 100%; background: var(--amber); border-radius: 2px; transition: width 0.4s; }
.mpb-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.game-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1.25rem; }
.game-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.game-row.done { border-color: var(--green-mid); cursor: default; }
.game-row.gr-locked { opacity: 0.45; cursor: not-allowed; }
.gr-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.gr-icon.green { background: var(--green-light); }
.gr-icon.amber { background: var(--amber-bg); }
.gr-icon.blue { background: #E6F1FB; }
.gr-info { flex: 1; }
.gr-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.gr-desc { font-size: 11px; color: var(--text-muted); }
.gr-right { text-align: right; }
.gr-pts { font-size: 11px; color: var(--amber-text); }
.gr-done-mark { font-size: 16px; color: var(--green-mid); }

/* ── LAUNCH ── */
.launch-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; text-align: center; }
.launch-icon { font-size: 48px; margin-bottom: 0.75rem; }
.launch-name { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.launch-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; }
.launch-meta { display: flex; justify-content: center; gap: 20px; margin-bottom: 1.25rem; }
.lm { text-align: center; }
.lm-val { font-size: 20px; font-weight: 600; }
.lm-label { font-size: 10px; color: var(--text-muted); }
.launch-tips { background: var(--bg); border-radius: var(--radius-sm); padding: 0.75rem 1rem; text-align: left; }
.lt-title { font-size: 10px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.05em; }
.lt-item { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; padding-left: 12px; position: relative; line-height: 1.4; }
.lt-item::before { content: "·"; position: absolute; left: 0; }

/* ── GAME CONTAINER ── */
#game-container { min-height: 300px; }

/* ── COMPLETION ── */
.complete-wrap { text-align: center; padding: 1.5rem 0 1rem; }
.complete-icon { font-size: 56px; margin-bottom: 0.75rem; }
.complete-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.complete-sub { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 1.25rem; }
.complete-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 1.25rem; }
.cstat { background: var(--bg); border-radius: var(--radius-sm); padding: 0.75rem; text-align: center; }
.cstat-val { font-size: 22px; font-weight: 600; }
.cstat-label { font-size: 10px; color: var(--text-muted); }
.new-badge-card { background: var(--amber-bg); border: 1px solid var(--amber); border-radius: var(--radius); padding: 1rem; display: flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; text-align: left; }
.nb-icon { font-size: 32px; flex-shrink: 0; }
.nb-title { font-size: 13px; font-weight: 600; color: var(--amber-text); margin-bottom: 2px; }
.nb-sub { font-size: 11px; color: var(--amber-text); opacity: 0.7; }

/* ── BUTTONS ── */
.btn {
  display: block; width: auto;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  border: 0.5px solid var(--border);
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text);
  transition: all 0.15s;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--green-dark); color: white; border-color: var(--green-dark); }
.btn.ghost { color: var(--text-muted); border-color: var(--border); }
.btn.full { width: 100%; margin-bottom: 8px; }
.btn.full:last-child { margin-bottom: 0; }

/* ── QUIZ GAME STYLES ── */
.quiz-wrap { padding: 0; }
.quiz-progress { display: flex; align-items: center; gap: 8px; margin-bottom: 1rem; }
.qp-bar-wrap { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.qp-bar { height: 100%; background: var(--amber); border-radius: 2px; transition: width 0.3s; }
.qp-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.quiz-pts { font-size: 11px; color: var(--amber-text); background: var(--amber-bg); padding: 3px 8px; border-radius: 10px; }
.quiz-q { font-size: 14px; line-height: 1.55; margin-bottom: 1rem; padding: 0.875rem 1rem; background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius); border-left: 3px solid var(--amber); }
.quiz-img { width: 100%; border-radius: var(--radius-sm); margin-bottom: 0.75rem; max-height: 180px; object-fit: cover; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 0.875rem; }
.quiz-opt { padding: 0.7rem 0.875rem; border: 0.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; background: var(--bg-card); color: var(--text); transition: all 0.15s; line-height: 1.35; text-align: left; }
.quiz-opt:active { transform: scale(0.98); }
.quiz-opt.correct { background: var(--green-light); border-color: var(--green-mid); color: var(--green-dark); pointer-events: none; }
.quiz-opt.wrong { background: var(--red-bg); border-color: var(--red); color: var(--red); pointer-events: none; }
.quiz-explain { font-size: 12px; color: var(--text-muted); background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px; line-height: 1.5; margin-bottom: 0.875rem; }
.lifelines { display: flex; gap: 6px; flex-wrap: wrap; }
.lifeline { display: flex; align-items: center; gap: 4px; padding: 5px 10px; border: 0.5px solid var(--border); border-radius: 10px; font-size: 11px; color: var(--text-muted); cursor: pointer; background: var(--bg); }
.lifeline.used { opacity: 0.3; pointer-events: none; }

/* ── SORTING GAME ── */
.sort-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.sort-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-sm); cursor: grab; font-size: 13px; }
.sort-item.dragging { opacity: 0.4; }
.sort-item.correct { border-color: var(--green-mid); background: var(--green-light); }
.sort-item.wrong { border-color: var(--red); background: var(--red-bg); }
.sort-handle { color: var(--text-muted); font-size: 16px; cursor: grab; }

/* ── MATCHING GAME ── */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 1rem; }
.match-col { display: flex; flex-direction: column; gap: 6px; }
.match-item { padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; background: var(--bg-card); line-height: 1.35; transition: all 0.15s; }
.match-item.selected { border-color: var(--amber); background: var(--amber-bg); }
.match-item.matched { border-color: var(--green-mid); background: var(--green-light); cursor: default; }
.match-item.wrong { border-color: var(--red); background: var(--red-bg); animation: shake 0.3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* ── RESPONSIVE ── */
@media (max-width: 400px) {
  .quiz-options { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: 1fr; }
}
