/* ==========================================================================
   arcade.css — CTYG Arcade theming + shared shell chrome. Phase 8.
   Darker, more digital than the marketing site, still inside the design
   system: base #0A0A0D, purple radial washes, faint orange wash, same
   2 fonts (Bebas Neue + DM Sans), orange only in its approved roles,
   purple only for arcade-identity touches (eyebrows, meta labels, XP,
   featured border, avatar gradient).
   Also carries the production-game compat shims scoped to .game-root so
   the four ported games keep their exact behavior inside the new shell.
   ========================================================================== */

/* ---------- 1. Arcade page atmosphere ---------- */
body.arcade {
  background: #0A0A0D;
  color: var(--white);
}
body.arcade::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 20% 0%, rgba(90,22,138,.40), transparent 60%),
    radial-gradient(700px 400px at 90% 30%, rgba(242,106,36,.12), transparent 60%);
}
@media (prefers-reduced-motion: no-preference) {
  body.arcade::before { background-attachment: fixed; }
}
.arcade .eyebrow { color: var(--purple-glow); }
.arcade .eyebrow::before { background: var(--purple-glow); }
.arcade .section-head p { color: rgba(255,255,255,.68); }
.arcade .page-wrap { position: relative; }

/* ---------- 2. Shell bar (every /arcade/* game route) ---------- */
.arc-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--pad-x);
  background: rgba(10,10,13,.92);
  border-bottom: 1px solid var(--line-light);
  position: relative;
  z-index: 110;
}
.arc-shell__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: .04em;
  margin-right: auto;
}
.arc-shell__brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line-light);
}
.arc-shell__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line-light);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  color: var(--white);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  min-height: 48px;
}
a.arc-shell__profile { cursor: pointer; }
.arc-shell__profile:hover { border-color: var(--purple-glow); }
.arc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--accent-deep));
  flex-shrink: 0;
}
.arc-shell__who { text-align: left; line-height: 1.25; min-width: 0; }
.arc-handle {
  display: block;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.arc-level {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--purple-glow);
}
.arc-xp {
  width: 110px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
  flex-shrink: 0;
}
.arc-xp__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--accent));
  transition: width var(--d-card) var(--ease);
}
.arc-shell__actions { display: flex; align-items: center; gap: 6px; }
.arc-shell__actions .icon-btn { border-color: var(--line-light); color: var(--white); }
.arc-shell__actions .icon-btn:hover { border-color: var(--purple-glow); }
@media (max-width: 640px) {
  .arc-shell__who, .arc-xp { display: none; }
  .arc-shell__brand { font-size: 1.15rem; }
}

/* ---------- 3. Shell settings modal ---------- */
.arc-modal { max-width: 480px; }
.arc-field { margin-bottom: 18px; }
.arc-field label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.arc-field input[type="text"] {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 14px;
  font: inherit;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line-light);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
}
.arc-field input[type="text"]:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--accent);
}
.arc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-light);
  font-weight: 600;
}
.arc-toggle-row small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.arc-switch {
  position: relative;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line-light);
  background: rgba(255,255,255,.10);
  cursor: pointer;
  flex-shrink: 0;
}
.arc-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--d-micro) var(--ease), background var(--d-micro) var(--ease);
}
.arc-switch[aria-checked="true"] { background: var(--accent-deep); border-color: var(--accent-deep); }
.arc-switch[aria-checked="true"]::after { transform: translateX(24px); background: #fff; }

/* ---------- 4. Game cards (hub) ---------- */
.game-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 899px) { .game-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (max-width: 599px) { .game-grid { grid-template-columns: 1fr; } }
.game-card {
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line-light);
  border-radius: var(--r-md);
  padding: clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--d-card) var(--ease), box-shadow var(--d-card) var(--ease), border-color var(--d-card) var(--ease);
}
@media (hover: hover) {
  .game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--purple-glow); }
}
.game-card__art {
  font-size: 3rem;
  line-height: 1;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-light);
}
.game-card h3 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  letter-spacing: .02em;
  margin: 0;
  color: var(--white);
}
.game-card__meta {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--purple-glow);
  text-transform: uppercase;
}
.game-card p { color: rgba(255,255,255,.72); margin: 0; font-size: var(--fs-body); }
.game-card .btn { margin-top: auto; align-self: flex-start; }
.game-card--featured {
  grid-column: 1 / -1;
  border: 1px solid rgba(192,132,252,.45);
  background:
    linear-gradient(rgba(46,10,73,.35), rgba(46,10,73,.35)),
    rgba(255,255,255,.045);
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 24px;
  align-items: center;
}
@media (max-width: 699px) { .game-card--featured { grid-template-columns: 1fr; } }
.tycoon-tag {
  display: inline-block;
  background: var(--accent-deep);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .22em;
  padding: 7px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

/* ---------- 5. Player profile panel ---------- */
.profile-card {
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line-light);
  border-radius: var(--r-lg);
  padding: clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 799px) { .profile-card { grid-template-columns: 1fr; } }
.p-id { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.p-id .arc-avatar { width: 56px; height: 56px; font-size: 1.1rem; }
.p-id h3 { margin: 0; font-size: 1.4rem; letter-spacing: .04em; text-transform: uppercase; }
.p-id .lvl { color: var(--purple-glow); font-weight: 700; letter-spacing: .18em; font-size: .78rem; }
.xp-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
}
.xp-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--accent));
  transition: width var(--d-card) var(--ease);
}
.xp-lbl {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-small);
  color: var(--muted);
  margin-top: 8px;
}
.handle-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.ach {
  border: 1px solid var(--line-light);
  border-radius: var(--r-sm);
  padding: 14px 12px;
  text-align: center;
  font-size: .82rem;
  background: rgba(255,255,255,.03);
}
.ach .ach-emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.ach b { display: block; font-size: .85rem; margin-bottom: 4px; }
.ach span { color: var(--muted); font-size: .75rem; line-height: 1.4; display: block; }
.ach.is-locked { opacity: .45; }
.ach.is-locked .ach-emoji { filter: grayscale(1); }
.scores { display: grid; gap: 10px; }
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line-light);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.03);
  font-size: .92rem;
}
.score-row b { font-weight: 700; }
.score-row span { color: var(--purple-glow); font-weight: 700; white-space: nowrap; }
.challenge {
  border: 1px dashed rgba(192,132,252,.5);
  border-radius: var(--r-md);
  padding: 20px;
  margin-top: 4px;
}
.challenge .tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--purple-glow);
  margin-bottom: 8px;
}
.challenge h4 { margin: 0 0 6px; font-size: 1.1rem; }
.challenge p { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }
.challenge p b { color: var(--accent); }

/* ---------- 6. Leaderboard overview ---------- */
.lb-overview { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; }
@media (max-width: 799px) { .lb-overview { grid-template-columns: 1fr; } }
.lb-panel {
  border: 1px solid var(--line-light);
  border-radius: var(--r-md);
  padding: clamp(20px, 3vw, 28px);
  background: rgba(255,255,255,.03);
}
.lb-panel h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: .03em;
  margin: 0 0 4px;
  color: var(--white);
}
.lb-panel .lb-sub { color: var(--muted); font-size: .82rem; margin: 0 0 14px; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: 8px;
  border-bottom: 1px solid var(--line-light);
  text-align: left;
}
.lb-table td { padding: 10px 8px; border-bottom: 1px solid var(--line-light); font-size: .95rem; }
.lb-table tr.top1 td { color: #ffd75e; font-weight: 800; }
.lb-table tr.top2 td { color: #d7dbe0; font-weight: 700; }
.lb-table tr.top3 td { color: #e09a5e; font-weight: 700; }
.lb-empty { color: var(--muted); padding: 18px 0; text-align: center; font-size: .92rem; }
.lb-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.lb-tab {
  border: 1px solid var(--line-light);
  background: transparent;
  color: var(--white);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}
.lb-tab[aria-pressed="true"] { border-color: var(--accent-deep); background: var(--accent-soft); color: var(--white); }

/* ---------- 7. Post-game actions row (injected into game-over screens) ---------- */
.arc-postgame {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-light);
  display: grid;
  gap: 10px;
}
.arc-postgame__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--purple-glow);
  text-transform: uppercase;
  text-align: center;
}
.arc-postgame__row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .arc-postgame__row { grid-template-columns: 1fr; } }
.arc-postgame .btn { width: 100%; margin: 0; }

/* ---------- 8. Arcade toast ---------- */
.arc-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-2);
  color: var(--white);
  border: 1px solid var(--purple-glow);
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: .92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-micro) var(--ease), transform var(--d-micro) var(--ease);
  z-index: 230;
  max-width: min(92vw, 480px);
  text-align: center;
}
.arc-toast--on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 9. Production-game compat shims (scoped, never global) ----------
   Battle + Crazy Day were built on production styles.css. These restore the
   exact tokens and button classes they use — scoped to .game-root only so
   the design-system tokens and components.css are never clobbered. */
.game-root {
  --card: #181824;
  --purple-bright: #5b3df0;
  --orange: #df4601;
  --orange-bright: #ff6a1a;
  --text: #f5f2ea;
  --muted: #a9a3b8;
  --radius: 16px;
  color: var(--text);
}
.game-root .btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 14px 30px;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, box-shadow .2s ease;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}
.game-root .btn:active { transform: scale(.96); }
.game-root .btn-primary {
  background: linear-gradient(135deg, var(--purple-bright), var(--orange));
  color: #fff;
  box-shadow: 0 6px 24px rgba(91,61,240,.4);
}
.game-root .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(223,70,1,.45); }
.game-root .btn-big { display: block; text-align: center; margin: 22px 0 10px; font-size: 1.1rem; padding: 17px 30px; }
.game-root .btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #2a2a3a;
  margin-top: 14px;
}
.game-root .btn-ghost:hover { color: var(--text); border-color: var(--purple-bright); }
.game-root .hidden { display: none !important; }
.game-root a { color: inherit; }

/* ---------- 10. Game page layout ---------- */
.arc-game-main { padding: 24px 0 64px; }
.arc-game-main .page-wrap { max-width: 1080px; }

/* Reduced motion: kill the decorative washes' fixed attachment and any
   arcade transitions that aren't essential. */
@media (prefers-reduced-motion: reduce) {
  .arc-xp__fill, .xp-track i { transition: none; }
  .game-card, .arc-toast { transition: none; }
}

/* ---------- Arcade form & button utilities (hub + shell) ---------- */
.handle-row input[type="text"] {
  flex: 1 1 180px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 14px;
  font: inherit;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line-light);
  color: var(--white);
}
.handle-row input[type="text"]::placeholder { color: rgba(255,255,255,.38); }
.handle-row input[type="text"]:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-sm { min-height: 44px; padding: 10px 18px; font-size: .9rem; }
.btn-accent { background: var(--accent); color: #231303; border: none; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-accent:disabled { opacity: .55; cursor: default; filter: none; }
