/* rpg.css — MathScape mobile gamified shell */

/* ── Shell layout ────────────────────────────────────────────── */
#rpg-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ── Stats bar ───────────────────────────────────────────────── */
.rpg-stats-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.rpg-stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.rpg-streak {
  background: rgba(227,179,65,0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
}

.rpg-level {
  background: rgba(88,166,255,0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 8px;
}

.rpg-daily {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 3px 8px;
  margin-left: auto;
}

.rpg-lv-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.rpg-xp-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.rpg-xp-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Scrollable content area ─────────────────────────────────── */
.rpg-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Onboarding ──────────────────────────────────────────────── */
.rpg-onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 24px;
  gap: 20px;
}

.rpg-welcome-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.rpg-welcome-sub {
  font-size: 16px;
  color: var(--text-dim);
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
}

.rpg-course-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 400px;
}

.rpg-course-chip {
  padding: 14px 20px;
  border-radius: 12px;
  border: 2px solid var(--chip-color, var(--border));
  background: var(--bg2);
  color: var(--chip-color, var(--text));
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
  transition: background 0.15s, transform 0.1s;
}

.rpg-course-chip:active {
  transform: scale(0.96);
}

.rpg-course-chip:hover {
  background: var(--bg3);
}

.rpg-chip-all {
  width: 100%;
  color: var(--text-dim);
}

/* ── Continue card ───────────────────────────────────────────── */
.rpg-continue-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  position: relative;
}

.rpg-course-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0,0,0,0.3);
  border: 1.5px solid var(--badge-color, var(--border));
  color: var(--badge-color, var(--text-dim));
  align-self: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rpg-card-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.rpg-card-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.4;
}

.rpg-xp-hint {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

.rpg-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.rpg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  min-height: 48px;
  transition: opacity 0.15s, transform 0.1s;
}

.rpg-btn:active {
  transform: scale(0.97);
}

.rpg-btn-primary {
  background: var(--accent);
  color: #fff;
  flex: 1;
}

.rpg-btn-primary:hover {
  opacity: 0.88;
}

.rpg-btn-secondary {
  background: var(--green);
  color: #fff;
  flex: 1;
}

.rpg-btn-secondary:hover {
  opacity: 0.88;
}

.rpg-btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  min-height: 36px;
}

/* ── Up-next list ────────────────────────────────────────────── */
.rpg-upnext {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.rpg-upnext-hd {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 10px 16px 6px;
}

.rpg-upnext-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.rpg-upnext-item:hover {
  background: var(--bg3);
}

.rpg-mini-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1.5px solid var(--badge-color, var(--border));
  color: var(--badge-color, var(--text-dim));
  background: rgba(0,0,0,0.3);
  white-space: nowrap;
}

.rpg-upnext-name {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-upnext-xp {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

/* ── Map tab ─────────────────────────────────────────────────── */
.rpg-map-hd {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 4px;
}

.rpg-map-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.rpg-map-item:hover {
  background: var(--bg3);
}

.rpg-map-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rpg-map-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-map-concept {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-map-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Profile tab ─────────────────────────────────────────────── */
.rpg-profile-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rpg-profile-lv {
  font-size: 16px;
  color: var(--text-dim);
}

.rpg-profile-lv-num {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}

.rpg-profile-xp {
  font-size: 14px;
  color: var(--text-dim);
}

.rpg-profile-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rpg-profile-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}

.rpg-profile-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s;
}

.rpg-profile-bar-label {
  font-size: 11px;
  color: var(--text-dim);
}

.rpg-profile-streak {
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
}

.rpg-profile-mastered {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.rpg-profile-courses-hd {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-top: 4px;
}

.rpg-profile-course-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.rpg-profile-course-label {
  width: 120px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpg-profile-mini-bar {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.rpg-profile-mini-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
}

.rpg-profile-frac {
  width: 50px;
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Bottom nav ──────────────────────────────────────────────── */
.rpg-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.rpg-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  min-height: 56px;
  gap: 2px;
  transition: color 0.15s;
}

.rpg-nav-btn.active {
  color: var(--accent);
}

.rpg-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.rpg-nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* ── Empty state ─────────────────────────────────────────────── */
.rpg-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Desktop: hide RPG shell by default (app.js controls it) ─── */
@media (min-width: 900px) {
  #rpg-shell:not([style]) {
    display: none;
  }
}
