/* The game (working title in js/shared/config.js) by Evenhand Games.
   One idea runs the whole look: the interface is lit by your own lamp.
   body.light-dim and body.light-dark shift the palette when your Beacon runs dry. */

:root {
  --night: #070b14;
  --deep: #0b111d;
  --panel: #101827;
  --raised: #172238;
  --line: #24324e;
  --line-soft: #1a2640;
  --gold: #ffc247;
  --gold-pale: #ffdf8a;
  --ember: #ff8a3c;
  --cyan: #5ce1ff;
  --teal: #2bb3c0;
  --magenta: #ff2e88;
  --violet: #9d86d6;
  --moss: #7bd88f;
  --text: #e9eef7;
  --muted: #93a4bf;
  --faint: #5d6c88;
  --glow: rgba(255, 194, 71, .32);
  --display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", system-ui, sans-serif;
  --body: "Avenir Next", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --r: 12px;
  --r-sm: 8px;
  --tab-h: 62px;
  --top-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
body.light-dim { --gold: #d99a45; --gold-pale: #e3bd83; --glow: rgba(217, 154, 69, .2); --cyan: #63bcd2; }
body.light-dark { --gold: #8794ad; --gold-pale: #aab4c8; --ember: #8794ad; --cyan: #7f93b3; --moss: #8794ad; --glow: rgba(135, 148, 173, .12); --panel: #0d1420; --raised: #131c2c; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: #04070d; color: var(--text); }
body { font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); text-decoration: none; }
img, svg { display: block; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: rgba(255, 194, 71, .35); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------------------------------------------------------------- frame */
.app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; background: var(--night); overflow: hidden; display: flex; flex-direction: column; }
@media (min-width: 520px) { .app { box-shadow: 0 0 0 1px var(--line-soft), 0 30px 80px rgba(0, 0, 0, .6); } }
.boot { flex: 1; display: grid; place-items: center; color: var(--faint); font-family: var(--display); letter-spacing: .3em; }

.topbar { flex: none; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 12px 0; display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, #0c1322, var(--night)); position: relative; z-index: 5; }
.topbar-title { font: 700 20px/1 var(--display); letter-spacing: .02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-res { display: flex; gap: 10px; }
/* The lamp line: how much light your Beacon has left. It is the top edge of every screen. */
.lampbar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line-soft); }
.lampbar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ember), var(--gold), var(--gold-pale)); box-shadow: 0 0 12px 1px var(--glow); transition: width .6s ease; }
body.light-dim .lampbar > i { animation: gutter 2.4s infinite; }
@keyframes gutter { 0%, 100% { opacity: 1; } 42% { opacity: .55; } 47% { opacity: .9; } 53% { opacity: .4; } 60% { opacity: 1; } }

.screen { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(24px + var(--safe-b)); scroll-behavior: smooth; }
.screen.flush { padding: 0; }
.screen::-webkit-scrollbar { width: 0; }

.tabbar { flex: none; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: #090e19; border-top: 1px solid var(--line-soft); position: relative; z-index: 5; }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font: 600 11px/1 var(--display); letter-spacing: .04em; position: relative; }
.tab .ic { width: 24px; height: 24px; }
.tab.on { color: var(--gold); }
.tab.on::before { content: ""; position: absolute; top: -1px; left: 26%; right: 26%; height: 2px; background: var(--gold); box-shadow: 0 0 10px 1px var(--glow); }
.tab .dot { position: absolute; top: 9px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--magenta); color: #fff; font: 700 10px/16px var(--body); text-align: center; }

/* ---------------------------------------------------------------- type */
.h1 { font: 700 28px/1.1 var(--display); letter-spacing: .01em; }
.h2 { font: 700 21px/1.15 var(--display); letter-spacing: .01em; }
.h3 { font: 700 16px/1.2 var(--display); letter-spacing: .02em; }
.label { font: 600 12px/1.2 var(--display); letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.gold { color: var(--gold); } .cyan { color: var(--cyan); } .magenta { color: var(--magenta); } .moss { color: var(--moss); }
.center { text-align: center; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- layout helpers */
.stack { display: flex; flex-direction: column; }
.hstack { display: flex; align-items: center; }
.gap-xs { gap: 4px; } .gap-s { gap: 8px; } .gap { gap: 12px; } .gap-l { gap: 18px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mt-s { margin-top: 8px; } .mt { margin-top: 14px; } .mt-l { margin-top: 24px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

/* ---------------------------------------------------------------- icons and pictures */
.ic { width: 20px; height: 20px; flex: none; color: inherit; }
.ic-s { width: 16px; height: 16px; } .ic-l { width: 28px; height: 28px; } .ic-xl { width: 40px; height: 40px; }
.art { width: 96px; height: 96px; flex: none; }
.av { border-radius: 50%; background: var(--raised); flex: none; object-fit: cover; box-shadow: 0 0 0 2px var(--line); }
.av-sm { width: 32px; height: 32px; } .av-md { width: 44px; height: 44px; } .av-lg { width: 72px; height: 72px; } .av-xl { width: 120px; height: 120px; }
.av-lit { box-shadow: 0 0 0 2px var(--gold), 0 0 14px var(--glow); }
.av-dim { box-shadow: 0 0 0 2px var(--ember); filter: saturate(.7); }
.av-dark { box-shadow: 0 0 0 2px var(--line); filter: grayscale(.85) brightness(.6); }
.portrait { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--r); background: var(--deep); }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 14px; }
.card-raised { background: var(--raised); border-color: var(--line); }
.card-lit { border-color: rgba(255, 194, 71, .45); box-shadow: inset 0 0 0 1px rgba(255, 194, 71, .08), 0 0 22px -6px var(--glow); }
/* A call for help: something a friend can do right now. */
.call { position: relative; background: linear-gradient(90deg, rgba(255, 194, 71, .1), transparent 60%), var(--panel); border: 1px solid rgba(255, 194, 71, .35); border-radius: var(--r); padding: 12px 12px 12px 16px; }
.call::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--gold); box-shadow: 0 0 10px 1px var(--glow); }
.call-danger { border-color: rgba(255, 46, 136, .45); background: linear-gradient(90deg, rgba(255, 46, 136, .12), transparent 60%), var(--panel); }
.call-danger::before { background: var(--magenta); box-shadow: 0 0 10px 1px rgba(255, 46, 136, .5); }
.notice { border-radius: var(--r-sm); padding: 10px 12px; background: rgba(92, 225, 255, .08); border: 1px solid rgba(92, 225, 255, .25); color: #cfefff; font-size: 13px; }
.notice-warn { background: rgba(255, 138, 60, .09); border-color: rgba(255, 138, 60, .35); color: #ffd9bd; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; border: 0; }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line-soft); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; }
button.row, a.row { background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; color: inherit; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 700 15px/1 var(--display); letter-spacing: .04em; white-space: nowrap; transition: transform .08s ease, filter .15s ease; user-select: none; }
.btn:active { transform: translateY(1px) scale(.985); filter: brightness(1.15); }
.btn[disabled], .btn.off { opacity: .42; pointer-events: none; }
/* The primary button is a lit sign plate with one cut corner. */
.btn-primary { background: linear-gradient(180deg, var(--gold-pale), var(--gold)); color: #1a1204; border-color: transparent; box-shadow: 0 0 20px -4px var(--glow); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%); border-radius: 10px 0 10px 10px; }
.btn-cyan { background: rgba(92, 225, 255, .12); border-color: rgba(92, 225, 255, .5); color: var(--cyan); }
.btn-danger { background: rgba(255, 46, 136, .12); border-color: rgba(255, 46, 136, .55); color: #ff7fb5; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-primary.btn-sm { clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%); border-radius: 8px 0 8px 8px; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 52px; font-size: 17px; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--muted); position: relative; flex: none; }
.iconbtn:active { background: var(--raised); }
.iconbtn .dot { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--magenta); color: #fff; font: 700 10px/16px var(--body); text-align: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--cyan); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 13px; background: var(--raised); border: 1px solid var(--line); font: 600 12px/1 var(--display); letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.chip-gold { color: var(--gold); border-color: rgba(255, 194, 71, .4); background: rgba(255, 194, 71, .08); }
.chip-cyan { color: var(--cyan); border-color: rgba(92, 225, 255, .4); background: rgba(92, 225, 255, .08); }
.chip-magenta { color: #ff7fb5; border-color: rgba(255, 46, 136, .45); background: rgba(255, 46, 136, .1); }
.chip .ic { width: 14px; height: 14px; }
.res { display: inline-flex; align-items: center; gap: 5px; font: 700 15px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--text); }
.res .ic { width: 17px; height: 17px; color: var(--gold); }
.res-cyan .ic { color: var(--cyan); } .res-moss .ic { color: var(--moss); } .res-muted .ic { color: var(--muted); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--raised); border: 1px solid var(--line); font: 700 11px/1.5 var(--display); letter-spacing: .06em; color: var(--muted); vertical-align: 1px; }

.seg { display: flex; padding: 3px; gap: 3px; background: var(--deep); border: 1px solid var(--line-soft); border-radius: 11px; }
.seg > button { flex: 1; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 700 14px/1 var(--display); letter-spacing: .04em; }
.seg > button.on { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 600 12px/1.2 var(--display); letter-spacing: .08em; color: var(--muted); }
.input, .textarea { width: 100%; min-height: 46px; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--deep); color: var(--text); font-size: 16px; }
.textarea { min-height: 84px; resize: none; line-height: 1.4; }
.input:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 194, 71, .14); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.check { display: flex; align-items: flex-start; gap: 10px; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; margin: 1px 0 0; }

.meter { height: 8px; border-radius: 4px; background: var(--deep); box-shadow: inset 0 0 0 1px var(--line-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .5s ease; }
.meter-cyan > i { background: linear-gradient(90deg, var(--teal), var(--cyan)); }
.meter-magenta > i { background: linear-gradient(90deg, #b81f63, var(--magenta)); }
.meter-moss > i { background: linear-gradient(90deg, #3f9a57, var(--moss)); }
.meter-thick { height: 14px; border-radius: 7px; } .meter-thick > i { border-radius: 7px; }

.timer { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--faint); }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--panel), var(--raised), var(--panel)); background-size: 200% 100%; animation: sk 1.4s linear infinite; min-height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- sheets and toasts */
#sheets { position: fixed; top: 0; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; z-index: 30; pointer-events: none; overflow: hidden; }
#sheets > .sheet-wrap { pointer-events: auto; }
.sheet-wrap { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; }
.scrim { position: absolute; inset: 0; background: rgba(3, 5, 10, .66); opacity: 0; transition: opacity .18s ease; }
.sheet { position: relative; max-height: 86%; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transform: translateY(102%); transition: transform .2s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -18px 50px rgba(0, 0, 0, .5); }
.sheet-tall { height: 86%; }
.sheet-wrap.in .scrim { opacity: 1; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 8px 8px 16px; }
.sheet-title { flex: 1; font: 700 20px/1.15 var(--display); letter-spacing: .01em; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.toasts { position: fixed; left: 0; right: 0; top: calc(12px + var(--safe-t)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast { max-width: 440px; padding: 10px 14px; border-radius: 10px; background: #1d2a44; border: 1px solid var(--line); color: var(--text); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: toast-in .2s ease; transition: opacity .3s ease, transform .3s ease; }
.toast-ok { border-color: rgba(255, 194, 71, .5); }
.toast-bad { border-color: rgba(255, 46, 136, .6); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* When your lamp is out, the whole app goes cold and says so. */
.darkbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #0a0f1a; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.darkbar .ic { color: var(--gold-pale); }
.offline { flex: none; padding: 6px 12px; background: #2a1020; color: #ffb3d1; font-size: 12px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; scroll-behavior: auto !important; }
}
