/* =========================================================================
 * style.css — UI theme & layout. Dark militaristic look, mobile-responsive.
 * ========================================================================= */
:root {
  --bg: #0a0c0f;
  --panel: #14181d;
  --panel2: #1c2127;
  --line: #2a3138;
  --text: #d6dbe0;
  --dim: #8a929c;
  --clay: #d97757;     /* Claude / Clawd clay-coral */
  --cream: #f7ead9;
  --accent: #d97757;   /* coral brand accent */
  --accent2: #39b6a0;
  --green: #3fbf5a;
  --red: #d6473b;
  --gold: #f0c44a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; touch-action: none; }

/* hidden safe-area probe — JS reads its computed padding (env insets) each resize */
#safe-probe {
  position: fixed; top: 0; left: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}
body {
  font-family: 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--text);
  user-select: none; -webkit-user-select: none;
  position: fixed; inset: 0;
}
/* hide the OS pointer over the play canvas — the in-raid crosshair replaces it
   (DOM menus sit above #game with their own cursor, so they're unaffected) */
#game { position: absolute; inset: 0; display: block; touch-action: none; background: var(--bg); cursor: none; }

#ui-root {
  position: absolute; inset: 0;
  display: flex; align-items: stretch; justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.screen {
  width: 100%; max-width: 920px; margin: auto;
  padding: 18px clamp(14px, 4vw, 40px) 40px;
  display: flex; flex-direction: column; gap: 16px;
  min-height: 100%;
}

/* ---- top bar ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 30px; height: 30px; flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(217,119,87,0.45)); }
.logo svg { width: 100%; height: 100%; display: block; }
.title { font-size: clamp(16px, 4.5vw, 24px); font-weight: 800; letter-spacing: 1px; }
.subtitle { font-size: 12px; color: var(--dim); }
.money { font-size: clamp(15px, 4vw, 20px); color: var(--gold); white-space: nowrap; }
.money b { font-weight: 800; }
.topright { display: flex; align-items: center; gap: 12px; }

/* language toggle */
.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lang-btn { background: var(--panel); color: var(--dim); border: none; padding: 6px 10px; font-family: inherit; font-weight: 800; font-size: 12px; cursor: pointer; }
.lang-btn + .lang-btn { border-left: 1px solid var(--line); }
.lang-btn.active { background: var(--accent2); color: #06110f; }
.lang-btn:not(.active):hover { background: var(--panel2); color: var(--text); }
.intro-langbar { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }

/* ---- hub ---- */
.statstrip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.statbox { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 6px; text-align: center; }
.sb-val { font-size: clamp(15px, 4vw, 20px); font-weight: 800; color: var(--accent2); }
.sb-label { font-size: 10px; color: var(--dim); letter-spacing: 1px; margin-top: 2px; }

.mainmenu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 6px; }
.menu-btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 18px; text-align: left; cursor: pointer; color: var(--text);
  transition: transform .08s, border-color .15s, background .15s; font-family: inherit;
}
.menu-btn:hover { border-color: var(--accent2); background: var(--panel2); transform: translateY(-2px); }
.menu-btn:active { transform: translateY(0); }
.menu-btn.primary { background: linear-gradient(135deg, #2a3a36, #1c2a27); border-color: var(--accent2); }
.menu-btn.primary:hover { border-color: var(--accent); }
.mb-title { font-size: clamp(16px, 4.5vw, 22px); font-weight: 800; letter-spacing: 1px; }
.mb-sub { font-size: 12px; color: var(--dim); margin-top: 4px; }

.hint { font-size: 12px; color: var(--dim); background: var(--panel); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 4px; line-height: 1.5; }

/* ---- location cards ---- */
.loc-grid { display: grid; gap: 12px; }
.loc-card { background: var(--panel); border: 1px solid var(--line); border-left-width: 5px; border-radius: 8px; padding: 16px; cursor: pointer; transition: transform .08s, background .15s; }
.loc-card:hover { background: var(--panel2); transform: translateX(3px); }
.loc-card.risk-1 { border-left-color: var(--green); }
.loc-card.risk-2 { border-left-color: var(--accent); }
.loc-card.risk-3 { border-left-color: var(--red); }
.loc-name { font-size: 19px; font-weight: 800; }
.loc-risk { font-size: 11px; color: var(--dim); letter-spacing: 1px; margin: 2px 0 8px; }
.loc-desc { font-size: 13px; color: var(--text); line-height: 1.5; }
.loc-meta { font-size: 12px; color: var(--gold); margin-top: 8px; }

/* ---- loadout ---- */
.loadout-body { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.ld-row { display: flex; align-items: center; gap: 12px; }
.ld-row label { width: 100px; font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--dim); flex-shrink: 0; }
.ld-select { flex: 1; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px 8px; font-family: inherit; font-size: 14px; }
.ld-count { width: 64px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px 6px; font-family: inherit; font-size: 14px; text-align: center; }
.loadout-info { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.li-title { font-size: 11px; letter-spacing: 1px; color: var(--dim); margin-bottom: 6px; }
.li-line { font-size: 13px; margin: 3px 0; color: var(--text); }
.li-line.bad { color: var(--red); }
.li-risk { font-size: 13px; color: var(--gold); margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.warn { font-size: 13px; color: var(--accent); text-align: center; }

/* ---- item grid / tiles ---- */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item { background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 8px 6px 6px; text-align: center; cursor: pointer; position: relative; transition: transform .06s, background .12s; min-height: 92px; }
.item:hover { background: var(--panel2); transform: translateY(-2px); }
.item.sel { outline: 2px solid var(--accent); }
.item-ico { width: 40px; height: 40px; border-radius: 8px; margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); overflow: hidden; }
.item-ico svg { width: 80%; height: 80%; display: block; }
.item-name { font-size: 11px; line-height: 1.2; color: var(--text); }
.item-qty { position: absolute; bottom: 4px; right: 6px; font-size: 11px; font-weight: 800; color: var(--gold); background: rgba(0,0,0,0.5); border-radius: 4px; padding: 0 4px; }
.item-tag { position: absolute; top: 3px; left: 3px; font-size: 8px; color: var(--dim); background: rgba(0,0,0,0.4); padding: 1px 3px; border-radius: 3px; letter-spacing: .5px; }

.detail { min-height: 56px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.d-name { font-size: 16px; font-weight: 800; }
.d-desc { font-size: 13px; color: var(--text); margin: 4px 0; }
.d-val { font-size: 12px; color: var(--gold); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--dim); padding: 30px; font-size: 14px; }

/* ---- trader ---- */
.tabs { display: flex; gap: 4px; }
.tab { flex: 1; text-align: center; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px 6px 0 0; cursor: pointer; font-weight: 700; letter-spacing: 1px; color: var(--dim); }
.tab.active { background: var(--panel2); color: var(--accent); border-bottom-color: var(--accent); }
/* category sub-tabs (weapons / armor / meds / ammo / valuables) */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 2px; }
.subtab { padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--dim); transition: background .12s, color .12s, border-color .12s; }
.subtab:hover { background: var(--panel2); color: var(--text); }
.subtab.active { background: var(--clay); color: #1a0f08; border-color: var(--clay); }
.trade-list { display: flex; flex-direction: column; gap: 6px; }
.trade-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.trade-row .item { min-height: auto; width: 60px; flex-shrink: 0; padding: 4px; }
.trade-row .item .item-ico { width: 28px; height: 28px; font-size: 15px; margin-bottom: 3px; }
.trade-row .item .item-name { font-size: 9px; }
.tr-info { flex: 1; min-width: 0; }
.tr-name { font-size: 14px; font-weight: 700; }
.tr-desc { font-size: 11px; color: var(--dim); margin-top: 2px; line-height: 1.4; }
.tr-price { font-size: 15px; font-weight: 800; color: var(--gold); white-space: nowrap; }
.tr-actions { display: flex; gap: 4px; flex-shrink: 0; }
button.mini { background: var(--accent2); color: #06110f; border: none; border-radius: 6px; padding: 8px 10px; font-weight: 800; cursor: pointer; font-family: inherit; font-size: 12px; }
button.mini:hover { filter: brightness(1.12); }
button.mini:active { transform: scale(.95); }

/* ---- settings ---- */
.settings-body { display: flex; flex-direction: column; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row label { font-size: 14px; font-weight: 600; }
.set-row input[type=range] { flex: 1; max-width: 240px; accent-color: var(--accent2); }
.toggle { padding: 8px 18px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; font-weight: 800; font-family: inherit; }
.toggle.on { background: var(--green); color: #06110a; }
.toggle.off { background: var(--panel2); color: var(--dim); }
button.danger { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 9px 14px; border-radius: 6px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13px; }
button.danger:hover { background: var(--red); color: #fff; }
.controls-help { border-top: 1px solid var(--line); padding-top: 12px; }
.ch-title { font-size: 12px; letter-spacing: 1px; color: var(--dim); margin-bottom: 8px; }
.ch { font-size: 12.5px; color: var(--text); line-height: 1.7; margin-bottom: 6px; }
.ch b { color: var(--accent2); }

/* ---- nav buttons ---- */
.navbtns { display: flex; gap: 10px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
button.nav { flex: 1; min-width: 120px; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 14px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 14px; letter-spacing: .5px; transition: background .12s, border-color .12s; }
button.nav:hover { background: var(--panel2); border-color: var(--accent2); }
button.nav.primary { background: var(--accent); color: #1a1206; border-color: var(--accent); }
button.nav.primary:hover { filter: brightness(1.1); }
button.nav.scav { border-color: var(--dim); color: var(--dim); }
button.nav.scav:hover { border-color: var(--text); color: var(--text); }
button.nav.danger { border-color: var(--red); color: var(--red); }

/* ---- intro / how-to-play ---- */
.intro { justify-content: center; align-items: center; text-align: center; gap: 14px; }
.intro-logo { width: 64px; height: 64px; filter: drop-shadow(0 0 14px rgba(217,119,87,0.5)); }
.intro-logo svg { width: 100%; height: 100%; display: block; }
.intro-title { font-size: clamp(20px, 6vw, 34px); font-weight: 900; letter-spacing: 2px; }
.intro-tag { font-size: 14px; color: var(--dim); }
.intro-steps { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 480px; }
.intro-step { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent2); border-radius: 8px; padding: 12px 14px; text-align: left; }
.is-title { font-size: 16px; font-weight: 800; }
.is-desc { font-size: 13px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.intro .warn { max-width: 480px; line-height: 1.55; }
.intro .navbtns { max-width: 480px; width: 100%; }

/* ---- results ---- */
.results { justify-content: center; align-items: center; text-align: center; }
.res-banner { font-size: clamp(28px, 9vw, 52px); font-weight: 900; letter-spacing: 3px; padding: 10px; }
.results.win .res-banner { color: var(--green); text-shadow: 0 0 24px rgba(63,191,90,0.5); }
.results.lose .res-banner { color: var(--red); text-shadow: 0 0 24px rgba(214,71,59,0.5); }
.res-table { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 18px; margin: 10px 0; }
.res-line { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.res-line:last-child { border-bottom: none; }
.res-line span { color: var(--dim); }
.res-line b { color: var(--text); }
.results .navbtns { margin-top: 14px; max-width: 420px; width: 100%; }

/* ---- overlay screens (pause / raid inventory) ---- */
.overlay-screen { background: rgba(8,10,13,0.92); justify-content: center; align-items: center; }
.pause-title { font-size: 30px; font-weight: 900; letter-spacing: 3px; text-align: center; }
.pause-menu { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; margin-top: 10px; }
button.big { padding: 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-family: inherit; font-weight: 800; font-size: 16px; letter-spacing: 1px; cursor: pointer; }
button.big.primary { background: var(--accent2); color: #06110f; border-color: var(--accent2); }
button.big.danger { border-color: var(--red); color: var(--red); }
button.big.danger:hover { background: var(--red); color: #fff; }
.inv-head { text-align: center; margin-bottom: 6px; }
.inv-val { font-size: 13px; color: var(--dim); margin-top: 4px; }
.inv-val b { color: var(--gold); }
.overlay-screen .item-grid { width: 100%; max-width: 600px; }
.equip-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.eq { font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; color: var(--text); }
.overlay-screen .navbtns { max-width: 360px; width: 100%; }

/* ---- global toast ---- */
#ui-toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--accent); font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#ui-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- story / narrative flavor ---- */
.intro-story {
  max-width: 480px; font-size: 13px; line-height: 1.6; color: var(--dim);
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--clay);
  border-radius: 6px; padding: 12px 14px; text-align: left;
}
.trader-greet {
  font-size: 13px; font-style: italic; color: var(--clay); line-height: 1.5;
  background: var(--panel); border-left: 3px solid var(--clay); border-radius: 4px;
  padding: 10px 12px;
}
.res-flavor { font-size: 14px; color: var(--dim); font-style: italic; line-height: 1.55; max-width: 420px; margin: -2px auto 6px; }

/* a hub menu button with a claimable contract waiting */
.menu-btn.ready { border-color: var(--gold); }
.menu-btn.ready .mb-sub { color: var(--gold); font-weight: 700; }

/* ---- contracts ---- */
.contracts-list { display: flex; flex-direction: column; gap: 10px; }
.contract-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.contract-card.active { border-left-color: var(--gold); background: var(--panel2); }
.contract-card.done { border-left-color: var(--green); opacity: 0.7; }
.contract-card.locked { opacity: 0.5; }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-title { font-size: 16px; font-weight: 800; }
.cc-badge { font-size: 10px; letter-spacing: 1px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.cc-badge.active { color: var(--gold); border-color: var(--gold); }
.cc-badge.done { color: var(--green); border-color: var(--green); }
.cc-desc { font-size: 13px; color: var(--text); line-height: 1.55; margin: 8px 0; }
.cc-bar { height: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; margin: 8px 0 4px; }
.cc-bar-fill { height: 100%; background: var(--gold); transition: width .2s; }
.cc-prog { font-size: 12px; color: var(--dim); }
.cc-reward { font-size: 13px; color: var(--gold); margin-top: 6px; }
.cc-claim { margin-top: 12px; }
.nav.disabled, .cc-claim.disabled { opacity: 0.45; filter: grayscale(0.5); }

/* ---- responsive ---- */
@media (max-width: 560px) {
  .statstrip { grid-template-columns: repeat(2, 1fr); }
  .mainmenu { grid-template-columns: 1fr; }
  .ld-row { flex-wrap: wrap; }
  .ld-row label { width: 100%; }
}
