/* ── App shell layout ────────────────────────────────────────────────────── */
#app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  flex-shrink: 0;
  z-index: 10;
}

#user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  transition: background 0.15s;
}
#user-badge:hover { background: rgba(255, 255, 255, 0.06); }

#top-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

#top-username {
  font-size: 14px;
  font-weight: 600;
}

#top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.top-icon-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.top-icon-btn:hover { background: rgba(255, 255, 255, 0.08); }

#inbox-count {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
#inbox-count.hidden { display: none; }

/* ── Screen container ────────────────────────────────────────────────────── */
main#screens {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

/* ── In-game: hide shell chrome so game takes full viewport ──────────────── */
#app-shell.in-game #top-bar,
#app-shell.in-game #bottom-nav {
  display: none;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.shell-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
}

.empty-hint {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  padding: 6px 0;
}

/* ── Option grid (Ranked / Unranked / etc) ───────────────────────────────── */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: center;
  color: var(--text);
}

.option-card:hover {
  border-color: var(--accent);
  background: rgba(85, 102, 255, 0.08);
}
.option-card:active { transform: scale(0.96); }

.option-icon { font-size: 28px; line-height: 1; }
.option-name { font-size: 14px; font-weight: 700; }
.option-sub  { font-size: 11px; color: var(--text-dim); }

/* ── Input row ───────────────────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.shell-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.shell-input:focus { border-color: var(--accent); }
.shell-input::placeholder { color: var(--text-dim); }

/* ── Pill button ─────────────────────────────────────────────────────────── */
.pill-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.pill-btn:hover  { background: #6677FF; }
.pill-btn:active { transform: scale(0.96); }
.pill-btn.sm     { padding: 7px 14px; font-size: 13px; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tab-row {
  display: flex;
  gap: 6px;
}

.tab-btn {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: flex; }

/* ── Coin shop ───────────────────────────────────────────────────────────── */
.coin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.coin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 18px 8px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, transform 0.1s;
}
.coin-card:hover  { border-color: var(--gold); }
.coin-card:active { transform: scale(0.96); }
.coin-card.popular {
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.05);
}

.coin-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #1A1200;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 2px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

.coin-amount { font-size: 18px; font-weight: 700; }
.coin-price  { font-size: 14px; color: var(--text-dim); }

/* ── VIP section ─────────────────────────────────────────────────────────── */
.vip-section {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.04);
}
.vip-title { color: var(--gold); }

.vip-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vip-perks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vip-perks li {
  font-size: 14px;
  color: var(--text);
  padding-left: 20px;
  position: relative;
}
.vip-perks li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-weight: 700;
}

.vip-btn {
  background: var(--gold);
  color: #1A1200;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
}
.vip-btn:hover:not(:disabled) { filter: brightness(1.1); }
.vip-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Profile ─────────────────────────────────────────────────────────────── */
.profile-hero {
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.avatar-xl {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.profile-identity {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-display-name { font-size: 19px; font-weight: 700; }

.profile-tier-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px 3px;
  color: var(--text-dim);
}
.profile-pid          { font-size: 13px; color: var(--text-dim); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 4px;
}

.stat-val { font-size: 18px; font-weight: 700; }
.stat-lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

.stats-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* ── Settings rows ───────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 13px 2px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover      { background: rgba(255, 255, 255, 0.04); }
.settings-row.danger     { color: var(--danger); justify-content: center; border-bottom: none; }

.row-arrow { color: var(--text-dim); font-size: 18px; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  gap: 12px;
}
.toggle-row:last-of-type { border-bottom: none; }

.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}
.toggle-row input[type="checkbox"]:checked { background: var(--accent); }
.toggle-row input[type="checkbox"]:checked::after { left: 20px; }

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
#bottom-nav {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: 62px;
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-family: inherit;
  padding: 8px 4px;
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover  { background: rgba(255, 255, 255, 0.04); }
.nav-btn.active { color: var(--accent); }

.nav-icon  { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Difficulty picker modal ─────────────────────────────────────────────── */
.diff-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.diff-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px 20px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.diff-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.02em;
}

.diff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.diff-btn:hover  { border-color: var(--accent); background: rgba(85,102,255,0.1); }
.diff-btn:active { transform: scale(0.97); }

.diff-icon   { font-size: 26px; line-height: 1; flex-shrink: 0; }
.diff-labels { display: flex; flex-direction: column; gap: 2px; }
.diff-name   { font-size: 14px; font-weight: 700; }
.diff-sub    { font-size: 11px; color: var(--text-dim); }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 32px;
  width: min(360px, 90vw);
}

#auth-logo-mark {
  font-size: 52px;
  line-height: 1;
}

#auth-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

#auth-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: -6px;
  margin-bottom: 8px;
}

#btn-google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff;
  color: #1A1A1A;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  transition: filter 0.15s, transform 0.1s;
}
#btn-google-signin:hover  { filter: brightness(0.94); }
#btn-google-signin:active { transform: scale(0.97); }

.google-icon-wrap {
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#btn-guest-skip {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
  margin-top: -8px;
  transition: color 0.15s;
}
#btn-guest-skip:hover { color: var(--text); }

#google-g {
  width: 22px;
  height: 22px;
  background: #4285F4;
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Name modal (onboarding + edit) ─────────────────────────────────────── */
.name-modal-sub {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: -8px;
}

.name-modal-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
  text-align: center;
}

/* ── Item-used notice in item panel ──────────────────────────────────────── */
.item-used-notice {
  padding: 14px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}
