/* ============================================================
 * Ashfall City — 2026 modern dark UI
 * Ambient mesh + film grain · glass panels · gradient accent
 * bento dashboard · view transitions · staggered motion
 * muted amber→ember · no neon
 * ============================================================ */

:root {
  /* layered slate */
  --bg:        #0b0e13;
  --bg-soft:   #10141b;
  --panel:     #161b23;
  --panel-2:   #1c222c;
  --panel-3:   #242c38;
  --border:   #2a323e;
  --border-2: #39424f;

  /* text */
  --text:     #d9e0e8;
  --text-mut: #8a97a6;
  --text-dim: #586574;

  /* gradient accent system (amber → ember) */
  --accent:    #c8a86c;
  --accent-2:  #9c7f4f;
  --accent-3:  #b0704a;        /* ember end */
  --accent-grad: linear-gradient(135deg, #cda672 0%, #c0835a 100%);
  --accent-soft: rgba(200, 168, 108, 0.14);
  --accent-glow: rgba(200, 130, 90, 0.28);
  --accent-line: linear-gradient(135deg, var(--accent), var(--accent-3) 70%);

  /* status colors — desaturated */
  --c-energy: #6f9bb0;
  --c-nerve:  #b07a6a;
  --c-happy:  #8fae7a;
  --c-hp:     #9a7a7a;

  --ok:  #7ea88a;
  --bad: #b06a6a;

  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-h2: 20px;
  --fs-h1: 24px;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-2: 0 10px 30px rgba(0,0,0,0.38);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  /* ambient mesh: muted amber/ember glow + cool slate, layered radials */
  background:
    radial-gradient(900px 520px at 88% -8%,  rgba(200,130,90,0.10), transparent 62%),
    radial-gradient(820px 600px at 5% 12%,   rgba(80,110,140,0.07), transparent 60%),
    radial-gradient(1100px 700px at 50% 115%, rgba(200,168,108,0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  position: relative;
  min-height: 100vh;
}

/* film grain overlay (SVG turbulence, very subtle) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.78  0 0 0 0 0.6  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
/* soft vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(0,0,0,0.42) 100%);
}

.muted { color: var(--text-mut); }
.dim   { color: var(--text-dim); }
.num, #cash, .hero-value, .big, .log-time,
input[type="number"] { font-variant-numeric: tabular-nums; }

.ico { display: inline-block; vertical-align: middle; flex: none; }

/* ---------- layout ---------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 228px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "nav    main";
  height: 100vh;
  max-width: 1360px;
  margin: 0 auto;
}

.app-header {
  grid-area: header;
  padding: 16px 26px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent), rgba(16, 20, 27, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  position: relative;
  z-index: 10;
}
.app-nav {
  grid-area: nav;
  padding: 16px 0;
  border-right: 1px solid var(--border);
  background: rgba(16, 20, 27, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
}
.app-main {
  grid-area: main;
  padding: 26px 30px 44px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.app-main::-webkit-scrollbar { width: 10px; }
.app-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
.app-main::-webkit-scrollbar-thumb:hover { background: var(--border-2); background-clip: content-box; }

/* ---------- header ---------- */
.header-top { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
#title {
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#title .ico { color: var(--accent); width: 22px; height: 22px; -webkit-text-fill-color: initial; }
.brand-tag {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.status-line {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  color: var(--text-mut);
}
.status-line.is-jail { color: var(--c-nerve); border-color: rgba(176,122,106,0.5); background: rgba(176,122,106,0.10); }
.status-line.is-hosp { color: var(--c-hp); border-color: rgba(154,122,122,0.5); background: rgba(154,122,122,0.10); animation: pulse 2s var(--ease) infinite; }
.status-line.is-free { color: var(--ok); border-color: rgba(126,168,138,0.45); background: rgba(126,168,138,0.10); }

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  margin-top: 14px;
}

/* bars */
#bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; max-width: 700px; }
.stat-bar { min-width: 0; }
.stat-bar-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-xs); color: var(--text-mut); margin-bottom: 6px;
}
.stat-bar-head .lbl { display: flex; align-items: center; gap: 6px; letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600; }
.stat-bar-head .lbl .ico { width: 13px; height: 13px; opacity: 0.85; }
.stat-bar-head .num { font-weight: 600; color: var(--text); }
.bar {
  height: 8px;
  background: var(--panel-3);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.35);
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s var(--ease);
  position: relative;
  background-size: 200% 100%;
}
.bar-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
  border-radius: 999px;
}
.c-energy { background-image: linear-gradient(90deg, #5a869b, #6f9bb0); }
.c-nerve  { background-image: linear-gradient(90deg, #9c6a5c, #b07a6a); }
.c-happy  { background-image: linear-gradient(90deg, #759669, #8fae7a); }
.c-hp     { background-image: linear-gradient(90deg, #846868, #9a7a7a); }

/* right cluster */
.header-right { display: flex; flex-direction: column; gap: 7px; align-items: flex-end; }
.header-right .row { display: flex; align-items: center; gap: 10px; }
#cash { font-size: 23px; font-weight: 700; letter-spacing: -0.01em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#bank-display { font-size: var(--fs-sm); color: var(--text-mut); }
#level { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.xp { width: 172px; }
.xp .bar { height: 5px; }
.xp-fill { background: var(--accent-grad); height: 100%; border-radius: 999px; transition: width 0.6s var(--ease); }
#xp-text { font-size: var(--fs-xs); color: var(--text-mut); text-align: right; margin-top: 3px; }

/* ---------- nav ---------- */
.nav-btn {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 18px; margin-bottom: 1px;
  background: transparent; border: none; border-radius: 0;
  color: var(--text-mut); font-size: var(--fs-lg); font-weight: 500;
  text-align: left; cursor: pointer; position: relative;
  transition: background 0.18s, color 0.18s;
}
.nav-btn .ico { width: 18px; height: 18px; opacity: 0.7; transition: opacity 0.18s, color 0.18s; }
.nav-btn:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.nav-btn:hover .ico { opacity: 1; }
.nav-btn.active { color: var(--text); font-weight: 600; background: var(--accent-soft); }
.nav-btn.active .ico { opacity: 1; color: var(--accent); }
.nav-btn.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-grad);
}

/* ---------- content ---------- */
.app-main h2 {
  font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.01em;
  margin: 0 0 6px; display: flex; align-items: center; gap: 9px;
}
.app-main h2 .ico { color: var(--accent); width: 20px; height: 20px; }
.app-main > p { margin: 0 0 18px; }

/* glass panels with gradient border on hover */
.glass {
  position: relative;
  background: linear-gradient(180deg, rgba(28,34,44,0.92), rgba(22,27,35,0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--accent-line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.28s var(--ease); pointer-events: none;
}
.glass:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-2); }
.glass:hover::after { opacity: 1; }

.card { /* keep legacy class as a glass panel */
  position: relative;
  background: linear-gradient(180deg, rgba(28,34,44,0.92), rgba(22,27,35,0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow-1);
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--accent-line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.28s var(--ease); pointer-events: none;
}
.card:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-2); }
.card:hover::after { opacity: 1; }
.card h3 {
  font-size: var(--fs-xs); margin: 0 0 11px; color: var(--text-mut);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  display: flex; align-items: center; gap: 7px;
}
.card h3 .ico { width: 14px; height: 14px; color: var(--accent); }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px; margin-bottom: 16px;
}
.stack { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: var(--fs-md);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.row:last-child { border-bottom: none; }
.pill-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-pill {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 3px;
  transition: border-color 0.18s, transform 0.18s var(--ease);
}
.stat-pill:hover { border-color: var(--border-2); transform: translateY(-1px); }
.stat-pill .big { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-pill .muted { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- bento dashboard ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas:
    "hero hero cash   level"
    "hero hero hp     atk"
    "stats stats loadout loadout"
    "stats stats record  record"
    "activity activity activity activity";
  gap: 14px;
  margin-bottom: 16px;
}
.b-hero     { grid-area: hero; }
.b-cash     { grid-area: cash; }
.b-level    { grid-area: level; }
.b-hp       { grid-area: hp; }
.b-atk      { grid-area: atk; }
.b-stats    { grid-area: stats; }
.b-loadout  { grid-area: loadout; }
.b-record   { grid-area: record; }
.b-activity { grid-area: activity; }

.b-hero { display: flex; flex-direction: column; justify-content: space-between; padding: 18px 20px; }
.b-hero h2 { font-size: 26px; margin-bottom: 6px; }
.b-hero .hero-status { margin-top: 14px; }

.bento .card { padding: 16px 18px; }

/* hero tile (kept for non-bento views & small tiles) */
.hero-tile {
  display: flex; align-items: center; gap: 13px;
  background: linear-gradient(180deg, rgba(28,34,44,0.92), rgba(22,27,35,0.92));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.hero-tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--accent-line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.28s var(--ease); pointer-events: none;
}
.hero-tile:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-2); }
.hero-tile:hover::after { opacity: 1; }
.hero-icon {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); border: 1px solid rgba(200,168,108,0.28);
  border-radius: var(--radius-sm); color: var(--accent); flex: none;
}
.hero-icon .ico { width: 22px; height: 22px; }
.hero-body { min-width: 0; }
.hero-label { font-size: var(--fs-xs); color: var(--text-mut); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600; }
.hero-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.hero-sub { font-size: var(--fs-sm); margin-top: 1px; }

/* action rows */
.action-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, rgba(28,34,44,0.92), rgba(22,27,35,0.92));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 15px; position: relative;
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.16s;
}
.action-row::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--accent-line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.24s var(--ease); pointer-events: none;
}
.action-row:hover { border-color: var(--border-2); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.action-row:hover::after { opacity: 0.7; }
.action-row.locked { opacity: 0.5; }
.action-title { font-size: var(--fs-lg); font-weight: 600; }
.action-meta { font-size: var(--fs-sm); margin-top: 3px; }

/* buttons */
.btn {
  background: var(--accent-grad);
  color: #1c1407;
  border: 1px solid transparent;
  padding: 8px 15px; border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: 600; cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s var(--ease), filter 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.sm { padding: 5px 11px; font-size: var(--fs-sm); }
.btn.ghost {
  background: transparent; color: var(--text); border-color: var(--border-2);
}
.btn.ghost:hover:not(:disabled) { background: var(--panel-3); box-shadow: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tag {
  display: inline-block; font-size: 10px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-2); border-radius: 999px;
  padding: 1px 8px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.5px;
  vertical-align: middle;
}

/* inputs */
input[type="number"] {
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 11px; font-size: var(--fs-md);
  font-family: inherit; width: 140px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="number"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* log */
.log { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.log-row {
  font-size: var(--fs-sm); color: var(--text-mut); padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04); display: flex; gap: 10px;
}
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--text-dim); flex: none; font-size: var(--fs-xs); }
.empty { font-style: italic; color: var(--text-dim); padding: 4px 0; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-3); border: 1px solid var(--border-2);
  color: var(--text); padding: 11px 20px; border-radius: var(--radius);
  font-size: var(--fs-md); font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  box-shadow: var(--shadow-2); z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- motion ---------- */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* staggered entrance — only when #content has .entering */
#content.entering .bento > *,
#content.entering .card-grid > *,
#content.entering .city-grid > *,
#content.entering .stack > *,
#content.entering > .card {
  animation: enter 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* view transitions (tab switch) */
#content { view-transition-name: panel; }
::view-transition-old(panel) { animation: vt-out 220ms var(--ease) forwards; }
::view-transition-new(panel) { animation: vt-in 260ms var(--ease-out) forwards; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(14px); } }

/* ---------- location badge (header) ---------- */
.loc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-mut);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--panel-2);
}
.loc-badge .ico { width: 13px; height: 13px; color: var(--accent); }

/* ---------- city / map ---------- */
.city-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.map-card { padding: 14px 16px 18px; }
.city-map {
  width: 100%;
  height: auto;
  display: block;
  max-height: 360px;
}
.map-edge { stroke: var(--border-2); stroke-width: 0.6; fill: none; }
.map-edge.dim { stroke: var(--border); stroke-dasharray: 1.2 1.6; opacity: 0.5; }
.map-node { cursor: default; }
.map-node circle { fill: var(--panel-3); stroke: var(--border-2); stroke-width: 0.5; transition: fill 0.18s, stroke 0.18s; }
.map-node.is-current circle { fill: var(--accent); stroke: var(--accent-2); stroke-width: 1; }
.map-node.is-locked circle { fill: var(--panel-2); stroke: var(--border); opacity: 0.6; }
.map-node.is-go circle { fill: var(--panel-2); stroke: var(--accent-2); stroke-width: 0.8; cursor: pointer; }
.map-node.is-go:hover circle { fill: var(--accent-soft); stroke: var(--accent); }
.map-label {
  fill: var(--text-mut);
  font-size: 2.7px;
  font-weight: 600;
  text-anchor: middle;
  font-family: "Inter", sans-serif;
  letter-spacing: 0.2px;
  pointer-events: none;
  text-transform: uppercase;
}
.map-node.is-current .map-label { fill: var(--accent); }
.map-node.is-locked .map-label { fill: var(--text-dim); }
.map-you { fill: #1c1407; font-size: 3.4px; text-anchor: middle; font-weight: 700; pointer-events: none; }
.map-lock { fill: var(--text-dim); font-size: 2.6px; text-anchor: middle; pointer-events: none; }
.map-hit { fill: transparent; pointer-events: all; cursor: pointer; }
.map-node:not(.is-go) .map-hit { pointer-events: none; }

.loc-card { display: flex; flex-direction: column; }
.loc-card h3 { color: var(--text); font-size: var(--fs-md); text-transform: none; letter-spacing: 0; font-weight: 700; }
.loc-card h3 .ico { color: var(--accent); }
.loc-desc { color: var(--text-mut); font-style: italic; margin: 0 0 12px; line-height: 1.55; }
.loc-summary { margin-bottom: 10px; }
.small { font-size: var(--fs-sm); }
.small-caps { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; margin: 0 0 8px; }

/* ---------- encounter modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.modal.show { display: flex; opacity: 1; }
.modal-card {
  width: min(420px, 92vw);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-2);
  text-align: center;
  animation: modal-in 0.3s var(--ease-out) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-2);
  border-radius: 50%;
  color: var(--accent);
}
.modal-icon .ico { width: 28px; height: 28px; }
.modal-card h3 { font-size: 17px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.modal-card p { margin: 0 0 18px; }
.modal-card .btn-row { gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* responsive */
@media (max-width: 980px) {
  .bento {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      "hero hero"
      "cash level"
      "hp atk"
      "stats stats"
      "loadout loadout"
      "record record"
      "activity activity";
  }
}
@media (max-width: 820px) {
  .city-grid { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; grid-template-areas: "header" "nav" "main"; }
  .app-nav {
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 6px 10px; display: flex; overflow-x: auto; gap: 4px;
  }
  .nav-btn { width: auto; padding: 8px 12px; margin: 0; border-radius: var(--radius-sm); }
  .nav-btn.active::before { display: none; }
  #bars { grid-template-columns: 1fr 1fr; }
  .header-grid { grid-template-columns: 1fr; }
  .header-right { align-items: flex-start; }
}
@media (max-width: 520px) {
  .bento { grid-template-columns: 1fr; grid-template-areas: "hero" "cash" "level" "hp" "atk" "stats" "loadout" "record" "activity"; }
}
/* ============================================================
 * Auth screen + account chrome
 * ============================================================ */
.config-notice {
  position: relative; z-index: 5;
  margin: 0; padding: 10px 16px;
  background: rgba(200,130,90,0.10);
  border-bottom: 1px solid var(--accent-soft);
  color: var(--text-mut);
  font-size: var(--fs-md);
}
.config-notice strong { color: var(--accent); }
.config-notice code { color: var(--accent); background: rgba(200,168,108,0.08); padding: 1px 5px; border-radius: 5px; }

.auth-screen {
  position: fixed; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 520px at 88% -8%,  rgba(200,130,90,0.10), transparent 62%),
    radial-gradient(820px 600px at 5% 12%,   rgba(80,110,140,0.07), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 26px 24px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-brand {
  font-weight: 800; font-size: var(--fs-h1);
  letter-spacing: 0.2px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.auth-bolt { color: var(--accent); filter: drop-shadow(0 0 6px var(--accent-glow)); }
.auth-card h2 { margin: 0; font-size: var(--fs-h2); }
.auth-sub { margin: -4px 0 6px; font-size: var(--fs-sm); }

.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field span {
  font-size: var(--fs-xs); letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-dim);
}
.auth-field input {
  width: 100%; padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-lg);
  font-family: inherit; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.auth-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-card .btn { width: 100%; margin-top: 2px; }
.auth-error { min-height: 16px; color: var(--bad); font-size: var(--fs-sm); }
.auth-secondary {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 4px;
}
.auth-link {
  background: none; border: none; cursor: pointer;
  color: var(--text-mut); font-size: var(--fs-sm);
  padding: 2px 0; transition: color 0.2s var(--ease);
  font-family: inherit;
}
.auth-link:hover { color: var(--accent); }
.auth-hint { font-size: var(--fs-xs); text-align: center; margin: 6px 0 0; color: var(--text-dim); }

/* account chip + logout in the header */
.user-box {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: auto;
  padding-left: 12px;
}
.user-box .user-name {
  font-size: var(--fs-sm); color: var(--accent);
  font-weight: 600; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-box .btn.sm { padding: 4px 10px; font-size: var(--fs-xs); }

/* Make the [hidden] attribute authoritative — .app{display:grid} and
   .auth-screen{display:flex} would otherwise override it and leave the
   auth screen / game visible when they should be hidden. */
[hidden] { display: none !important; }
.auth-hint { font-size: var(--fs-xs); text-align: center; margin: 6px 0 0; color: var(--text-dim); }
