/* Embermarch — ice-age FTL. Warm ember UI over a cold world. */

:root {
  --night: #0d1420;
  --panel: rgba(16, 20, 30, 0.86);
  --ink: #f3ead6;
  --dim: #b7ab92;
  --ember: #ff9e4f;
  --flame: #ffc46b;
  --ice: #8fd0ff;
  --blood: #ff6b5e;
  --moss: #9fd08a;
  --line: rgba(255, 158, 79, 0.3);
  --edge: max(14px, env(safe-area-inset-left, 0px));
  font-family: 'Chakra Petch', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--night); color: var(--ink); }
body { -webkit-font-smoothing: antialiased; font-size: 14px; }
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 46%, rgba(5, 8, 14, 0.28) 76%, rgba(5, 8, 14, 0.62) 120%); }
#hurt { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 30, 20, 0.5) 100%); transition: opacity 0.5s; }
#hurt.flash { opacity: 1; transition: opacity 0.06s; }

/* ---------------------------------------------------------------- chrome */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; color: var(--flame); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(10, 13, 20, 0.68);
  backdrop-filter: blur(8px); font-weight: 700; font-size: 12px; letter-spacing: 0.08em;
  transition: color 0.15s, background 0.15s, transform 0.15s; position: relative; overflow: hidden;
}
.chip:hover, .chip:focus-visible { color: #1a1108; background: var(--ember); outline: none; transform: translateY(-1px); }
.home { position: fixed; z-index: 60; top: max(14px, env(safe-area-inset-top, 0px)); left: var(--edge); }
#mute { position: fixed; z-index: 60; top: max(14px, env(safe-area-inset-top, 0px)); left: calc(var(--edge) + 118px); width: 40px; padding: 0; }
#mute.off { opacity: 0.5; text-decoration: line-through; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); overflow-y: auto;
}
/* Light shade so event/camp 3D vignettes stay readable behind the panel */
.screen.shade { background: rgba(6, 9, 15, 0.38); backdrop-filter: blur(1.5px); }
#eventscreen.shade,
#campscreen.shade,
#traderscreen.shade,
#elderscreen.shade { background: rgba(6, 9, 15, 0.28); backdrop-filter: none; }

.title-card, .panel {
  background: linear-gradient(150deg, rgba(26, 24, 30, 0.94), rgba(12, 14, 22, 0.9));
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.05);
}
.title-card { max-width: 640px; padding: 34px 36px; text-align: center; }
.screen .panel { max-width: 560px; width: min(560px, 100%); padding: 26px 28px; text-align: center; }
.screen .panel.wide { max-width: 780px; width: min(780px, 100%); }

.kicker { color: var(--ember); font-size: 12px; font-weight: 700; letter-spacing: 0.26em; margin: 0 0 10px; }
h1 { font-family: Bungee, 'Chakra Petch', sans-serif; font-size: clamp(40px, 9vw, 74px); line-height: 0.95; margin: 6px 0 14px; color: var(--flame); text-shadow: 0 0 34px rgba(255, 158, 79, 0.35); }
h1 span { display: block; color: var(--ice); text-shadow: 0 0 30px rgba(143, 208, 255, 0.4); }
h2 { font-family: Bungee, 'Chakra Petch', sans-serif; font-size: clamp(22px, 4.6vw, 34px); margin: 4px 0 12px; color: var(--flame); }
.lede, .prose { color: var(--ink); font-size: 15px; line-height: 1.55; margin: 0 auto 16px; max-width: 54ch; }
.lede b, .prose b { color: var(--flame); }
.story {
  max-width: 48ch; margin: 0 auto 16px; text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.18);
}
.story summary {
  cursor: pointer; color: var(--dim); font-size: 12px; font-weight: 700;
  letter-spacing: 0.14em; padding: 10px 0; list-style: none;
}
.story summary::-webkit-details-marker { display: none; }
.story summary::before { content: '▸ '; color: var(--ember); }
.story[open] summary::before { content: '▾ '; }
.story p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--ink); }
.runes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.runes span { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--dim); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 5px 12px; }
.controls-hint, .hint { color: var(--dim); font-size: 12px; line-height: 1.5; margin: 14px 0 0; }
.hint b { color: var(--flame); font-weight: 700; }
.tend-split { margin: 0 0 12px; text-align: left; max-width: none; }

.primary, .secondary {
  display: inline-block; min-height: 46px; padding: 12px 26px; border-radius: 12px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.06em; border: 1px solid transparent;
}
.primary { background: linear-gradient(160deg, var(--flame), var(--ember)); color: #221204; box-shadow: 0 8px 26px rgba(255, 158, 79, 0.34); }
.quality-control { display: inline-flex; align-items: center; gap: 9px; margin-top: 12px; color: rgba(232, 221, 196, 0.72); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; }
.quality-control select { min-height: 34px; padding: 5px 30px 5px 10px; border: 1px solid rgba(143, 208, 255, 0.28); border-radius: 7px; background: rgba(8, 14, 24, 0.88); color: var(--ice); font: 600 12px 'Chakra Petch', sans-serif; letter-spacing: 0.06em; cursor: pointer; }
.quality-control select:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }
.primary:hover { filter: brightness(1.08); }
.secondary, .secondary.link { background: transparent; border-color: var(--line); color: var(--flame); text-decoration: none; }
.secondary:hover { background: rgba(255, 158, 79, 0.12); }
.choicerow { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud .panel { pointer-events: auto; }

#topbar { position: fixed; top: max(60px, calc(env(safe-area-inset-top, 0px) + 46px)); left: var(--edge); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#vitals { padding: 10px 14px; text-align: left; min-width: min(320px, 88vw); }
.hullrow { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.1em; }
.hullrow b { color: var(--flame); }
.hullrow span { color: var(--dim); font-size: 12px; min-width: 44px; }
.resrow { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; color: var(--dim); }
.resrow b { color: var(--flame); }
.goalline {
  margin: 8px 0 0; padding-top: 7px; border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px; line-height: 1.4; color: var(--ice); letter-spacing: 0.02em; font-weight: 600;
}
.goalline.danger { color: #ffb3a8; }
.panel.warn { padding: 8px 14px; color: var(--ice); font-weight: 700; font-size: 12px; letter-spacing: 0.1em; border-color: rgba(143, 208, 255, 0.5); animation: frostpulse 2.2s infinite; max-width: 280px; }
.panel.warn.night { color: #f0c98a; border-color: rgba(255, 158, 79, 0.45); animation: nightpulse 2.6s infinite; }
@keyframes frostpulse { 50% { box-shadow: 0 0 24px rgba(143, 208, 255, 0.35); } }
@keyframes nightpulse { 50% { box-shadow: 0 0 22px rgba(255, 158, 79, 0.3); } }
#pausebtn { pointer-events: auto; }

.bar { position: relative; width: 130px; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { position: absolute; inset: 0; width: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--moss), #d3e08a); transform-origin: left; transition: transform 0.25s; }
.bar.red i { background: linear-gradient(90deg, #d0453a, var(--blood)); }
.bar.amber i { background: linear-gradient(90deg, var(--ember), var(--flame)); transition: transform 0.1s linear; }

/* Height reserved for the social dock pills (bottom-right, z-index 9000+)
   so the power tray and crew chips never sit under them. */
:root { --dock-clear: 74px; }

#log { position: fixed; left: var(--edge); bottom: calc(var(--dock-clear) + 176px); display: flex; flex-direction: column; gap: 4px; max-width: min(400px, 48vw); pointer-events: none; }
#log p { margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); opacity: 0.94; }
#log p.bad { color: #ffb3a8; }
#log p.good { color: #c9e8ad; }
#log p.sys { color: var(--ice); }

/* fight panel */
#fightbar { position: fixed; right: max(14px, env(safe-area-inset-right, 0px)); top: max(60px, calc(env(safe-area-inset-top, 0px) + 46px)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 22; }
#enemypanel, #weapons { padding: 10px 14px; text-align: left; min-width: 224px; }
.enemyname b { color: var(--blood); font-size: 15px; }
.enemyname span { color: var(--dim); font-size: 12px; margin-left: 6px; }
#enemypanel .bar { width: 100%; margin-top: 6px; }
.fight-hint { margin: 6px 0 0; font-size: 11px; color: var(--dim); letter-spacing: 0.04em; }
#targets { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
#targets button {
  flex: 1; min-height: 42px; padding: 5px 6px; border-radius: 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--ink); background: rgba(255, 255, 255, 0.08); border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.15;
}
#targets button small {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; color: var(--dim); text-transform: lowercase;
}
#targets button.on { border-color: var(--blood); color: #ffd3cc; background: rgba(208, 69, 58, 0.25); }
#targets button.on small { color: #ffb8ae; }
#targets button.broken { opacity: 0.35; text-decoration: line-through; }
.weapon { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.weapon.gated { opacity: 0.55; }
.wlabel { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--dim); }
.wlabel em { font-style: normal; color: var(--flame); font-size: 11px; font-weight: 600; }
#weapons .bar { width: 108px; }
.gate-hint { margin: -2px 0 8px; font-size: 11px; color: var(--ember); line-height: 1.3; }
#puffs { display: flex; gap: 5px; }
#puffs i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); }
#puffs i.on { background: #cfd8d4; box-shadow: 0 0 10px rgba(220, 230, 225, 0.7); }
#flee { width: 100%; justify-content: center; }
#flee i { position: absolute; inset: 0; background: rgba(143, 208, 255, 0.3); transform-origin: left; transform: scaleX(0); }
#flee.on { border-color: var(--ice); color: var(--ice); }

/* power tray */
#tray { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-clear) + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; align-items: flex-end; z-index: 21; pointer-events: auto; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
.coalpill {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; min-height: 72px; padding: 8px 10px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--ember); color: var(--flame); gap: 2px;
  box-shadow: 0 0 16px rgba(255, 158, 79, 0.18);
}
.coalpill b { font-size: 22px; font-family: Bungee, sans-serif; line-height: 1; color: var(--flame); }
.coalpill span { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--dim); text-transform: uppercase; }
.coalpill.empty { border-color: rgba(255, 255, 255, 0.12); box-shadow: none; }
.coalpill.empty b { color: var(--dim); }
#systems { display: flex; gap: 8px; }
.sysbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 86px;
}
.sysbox .icon { font-size: 18px; line-height: 1; }
.sysbox .nm { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; color: var(--dim); white-space: nowrap; }
.sysbox .role { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; color: var(--ember); text-transform: uppercase; }
.pips { display: flex; gap: 3px; }
.pips i { width: 11px; height: 15px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.14); }
.pips i.on { background: linear-gradient(180deg, var(--flame), var(--ember)); box-shadow: 0 0 8px rgba(255, 158, 79, 0.6); }
.pips i.dmg { background: rgba(208, 69, 58, 0.55); border-color: var(--blood); }
.sysbtns { display: flex; gap: 4px; }
.sysbtns button {
  width: 30px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--flame); font-size: 14px; font-weight: 700; line-height: 1;
}
.sysbtns button:hover { background: rgba(255, 158, 79, 0.2); }
.sysbox.hit { animation: syshit 0.5s; }
@keyframes syshit { 0%, 60% { border-color: var(--blood); box-shadow: 0 0 18px rgba(255, 107, 94, 0.6); } }

#crewbar { display: flex; flex-direction: column; gap: 5px; max-width: 200px; }
.crewchip {
  display: flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 5px 10px 5px 5px; min-height: 34px; color: var(--ink); font-size: 12px; font-weight: 600;
  text-align: left;
}
.crewchip .dot {
  width: 28px; height: 28px; border-radius: 50%; flex: none; overflow: hidden;
  border: 1.5px solid rgba(255, 196, 107, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  background-size: cover; background-position: center 20%;
  background-color: rgba(255, 255, 255, 0.1);
}
.crewchip .dot img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block;
}
.crewchip .meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.crewchip .meta b { font-size: 12px; font-weight: 700; line-height: 1.1; }
.crewchip .meta small { color: var(--dim); font-size: 10px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crewchip .hp { width: 34px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); overflow: hidden; flex: none; }
.crewchip .hp i { display: block; height: 100%; background: var(--moss); }
.crewchip:hover { border-color: var(--flame); }

/* Event oil painting + optional speaker chip */
.event-panel { max-width: 620px !important; width: min(620px, 100%) !important; padding-top: 16px !important; }
.event-art-wrap {
  position: relative; margin: -4px -8px 14px; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255, 158, 79, 0.28);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.35); aspect-ratio: 16 / 9;
}
#eventart {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: center;
}
#eventart[hidden] { display: none; }
#eventspeaker {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: rgba(10, 13, 20, 0.78); border: 1px solid rgba(255, 196, 107, 0.4);
  backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
#eventspeaker img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: center 20%;
  border: 1.5px solid rgba(255, 196, 107, 0.55);
}
#eventspeaker span {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--flame);
  max-width: 12ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crewmenu { position: fixed; z-index: 65; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 5px; backdrop-filter: blur(10px); max-width: 260px; }
.crewmenu-head { display: flex; gap: 8px; align-items: flex-start; padding: 2px 4px 4px; }
.crewmenu-av {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: center 20%;
  border: 1.5px solid rgba(255, 196, 107, 0.5); flex: none;
}
.crewmenu b { font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
.crewmenu .bonus { font-size: 11px; color: var(--flame); line-height: 1.35; padding: 2px 0 4px; }
.crewmenu button { min-height: 34px; border-radius: 8px; border: 1px solid transparent; background: rgba(255, 255, 255, 0.07); color: var(--ink); font-size: 13px; text-align: left; padding: 5px 10px; }
.crewmenu button.on { border-color: var(--ember); color: var(--flame); }

/* tutorial + first-fight coach */
#tutor, #fightcoach {
  position: fixed; z-index: 45; top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%); width: min(560px, 94vw);
  background: linear-gradient(150deg, rgba(20, 28, 40, 0.95), rgba(10, 14, 24, 0.92));
  border: 1px solid rgba(143, 208, 255, 0.45); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 0 26px rgba(143, 208, 255, 0.18);
  padding: 12px 16px; backdrop-filter: blur(10px);
}
#fightcoach { border-color: rgba(255, 158, 79, 0.5); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 158, 79, 0.2); }
#tutor .kicker, #fightcoach .kicker { color: var(--ice); margin: 0 0 6px; font-size: 12px; }
#fightcoach .kicker { color: var(--ember); }
#tutortext, #fightcoach p { margin: 0 0 10px; font-size: 14px; line-height: 1.55; color: var(--ink); }
#fightcoach p b { color: var(--flame); }
#fightcoach { display: flex; flex-direction: column; align-items: flex-end; }
#fightcoach p { align-self: stretch; }
.tutrow { display: flex; gap: 8px; justify-content: flex-end; }
button.small { min-height: 36px; padding: 7px 16px; font-size: 13px; border-radius: 9px; }
.tut-glow {
  outline: 2px solid var(--ice) !important; border-radius: 12px;
  box-shadow: 0 0 0 5px rgba(143, 208, 255, 0.22), 0 0 26px rgba(143, 208, 255, 0.55) !important;
  animation: tutpulse 1.4s infinite;
}
@keyframes tutpulse {
  50% { box-shadow: 0 0 0 9px rgba(143, 208, 255, 0.1), 0 0 34px rgba(143, 208, 255, 0.75); }
}

/* pause flag */
#pauseflag { position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 30; text-align: center; pointer-events: none; }
#pauseflag b { display: block; font-family: Bungee, sans-serif; font-size: 34px; color: var(--ice); text-shadow: 0 0 30px rgba(143, 208, 255, 0.6); letter-spacing: 0.1em; }
#pauseflag small { color: var(--dim); font-size: 13px; }

/* part markers over the beast */
#markers { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.marker { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.marker .ring { width: 26px; height: 26px; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 50%; }
.marker.target .ring { border-color: var(--blood); box-shadow: 0 0 14px rgba(255, 107, 94, 0.8); animation: lockpulse 1s infinite; }
.marker span { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; color: var(--ink); text-shadow: 0 1px 3px #000; }
.marker.broken { opacity: 0.35; }
.marker.broken .ring { border-style: dashed; }
.marker.windup .ring { border-color: #ffb03a; box-shadow: 0 0 18px rgba(255, 176, 58, 0.9); animation: windpulse 0.35s infinite; }
.marker.windup span { color: #ffb03a; }
@keyframes windpulse { 50% { transform: scale(1.35); } }
@keyframes lockpulse { 50% { transform: scale(1.18); } }

/* ---------------------------------------------------------------- map */
#mapcanvas { width: 100%; height: auto; border-radius: 10px; background: rgba(8, 11, 18, 0.6); border: 1px solid rgba(255, 255, 255, 0.08); touch-action: manipulation; }
#mapchoices { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 12px; flex-wrap: wrap; min-height: 58px; }
#mapchoices .hint { margin: 0; }
.mapinfo {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px;
  background: rgba(255, 158, 79, 0.1); max-width: 520px;
}
.mapinfo .mi-icon { font-size: 24px; }
.mapinfo .mi-text { display: flex; flex-direction: column; gap: 2px; }
.mapinfo .mi-text b { color: var(--flame); font-size: 14px; letter-spacing: 0.04em; }
.mapinfo .mi-text small { color: var(--ink); font-size: 12px; line-height: 1.4; }
.mapinfo .mi-go {
  margin-left: 6px; padding: 10px 18px; border-radius: 10px; border: none;
  background: linear-gradient(160deg, var(--flame), var(--ember)); color: #221204;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
#mapchoices button {
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 158, 79, 0.1); color: var(--flame); font-weight: 700; font-size: 14px; letter-spacing: 0.05em;
}
#mapchoices button:hover { background: rgba(255, 158, 79, 0.28); }
.maprow { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.maprow .hint { margin: 0; }

/* tend / trader / elder lists */
#tendlist, #traderstock, #blessings, #eventchoices { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; }
.rowbtn {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left;
  min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: var(--ink); font-size: 14px; font-weight: 600;
}
.rowbtn:hover:not(:disabled) { background: rgba(255, 158, 79, 0.16); }
.rowbtn:disabled { opacity: 0.4; cursor: default; }
.rowbtn .cost { color: var(--flame); font-weight: 700; white-space: nowrap; }
.rowbtn small { display: block; color: var(--dim); font-size: 12px; font-weight: 400; }
#eventresulttext { color: var(--flame); }

/* Event choices: action text + terse risk/reward pills */
.rowbtn.event-choice { align-items: flex-start; padding: 11px 14px; }
.rowbtn.event-choice .choice-main {
  display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1;
}
.rowbtn.event-choice .choice-text { font-size: 14px; font-weight: 600; line-height: 1.3; }
.rowbtn.event-choice .choice-risk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 6px;
}
.rowbtn.event-choice .riskline {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.rowbtn.event-choice .riskor {
  color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0 2px;
}
.rowbtn.event-choice .odds {
  color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  min-width: 2.4em;
}
.rowbtn.event-choice .gainpill {
  padding: 3px 9px; font-size: 12px; letter-spacing: 0.02em;
}
.rowbtn.event-choice .gainpill.cost {
  border-style: dashed;
}

/* game over */
#end-stats { display: flex; gap: 18px; justify-content: center; margin: 10px 0 18px; flex-wrap: wrap; }
#end-stats div { text-align: center; }
#end-stats b { display: block; font-size: 24px; color: var(--flame); font-family: Bungee, sans-serif; }
#end-stats small { color: var(--dim); font-size: 12px; letter-spacing: 0.1em; }
#gameover .secondary.link { margin-left: 10px; min-height: 0; padding: 12px 18px; }

/* ---------------------------------------------------------------- phones */
@media (max-width: 760px) {
  #log { bottom: calc(var(--dock-clear) + 206px); max-width: 60vw; }
  #topbar { top: max(58px, calc(env(safe-area-inset-top, 0px) + 44px)); }
  .bar { width: 96px; }
  #fightbar { top: auto; bottom: calc(var(--dock-clear) + 118px + env(safe-area-inset-bottom, 0px)); right: 8px; flex-direction: row; align-items: flex-end; }
  #enemypanel, #weapons { min-width: 0; padding: 8px 10px; }
  #weapons .bar { width: 74px; }
  #tray { gap: 6px; }
  .sysbox { min-width: 64px; padding: 6px 7px; }
  .sysbox .nm { font-size: 12px; }
  #crewbar { flex-direction: row; flex-wrap: wrap; max-width: 96vw; }
  .crewchip .dot { width: 26px; height: 26px; }
  .event-art-wrap { margin: -2px -4px 12px; }
  .title-card { padding: 24px 20px; }
}

/* ---------------------------------------------------------------- deck fire */
#firemark {
  position: fixed; z-index: 25; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none; text-align: center;
}
#firemark .fm-ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid rgba(255, 107, 94, 0.9);
  background:
    conic-gradient(rgba(143, 208, 255, 0.85) var(--p, 0%), transparent var(--p, 0%));
  box-shadow: 0 0 22px rgba(255, 107, 94, 0.7);
  animation: firepulse 0.6s infinite;
}
#firemark.aim .fm-ring { border-color: var(--flame); }
#firemark.smother .fm-ring { animation: none; border-color: var(--ice); box-shadow: 0 0 20px rgba(143, 208, 255, 0.8); }
#firemark .fm-label {
  color: #ffd9d4; font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-shadow: 0 1px 4px #000; background: rgba(10, 8, 12, 0.7);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
#firemark.smother .fm-label { color: var(--ice); }
@keyframes firepulse { 50% { transform: scale(1.18); } }

/* ---------------------------------------------------------------- event loot pills */
#eventgains { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 2px 0 14px; }
.gainpill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 13px; border-radius: 999px; font-size: 14px; font-weight: 700;
  letter-spacing: 0.03em;
}
.gainpill.gain { color: #b6f0a0; background: rgba(120, 220, 110, 0.14); border: 1px solid rgba(120, 220, 110, 0.45); }
.gainpill.loss { color: #ffb3a8; background: rgba(255, 107, 94, 0.12); border: 1px solid rgba(255, 107, 94, 0.45); }
.gainpill.neutral { color: var(--dim); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); }

/* ---------------------------------------------------------------- post-combat summary */
#combatscreen .panel { max-width: 620px; }
#cs-kicker.fled { color: var(--ice); }
.cs-cols { display: flex; gap: 14px; margin: 12px 0 6px; }
.cs-col { flex: 1; min-width: 0; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 10px 12px; background: rgba(0, 0, 0, 0.18); }
.cs-head { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; margin: 0 0 8px; }
.cs-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.cs-pills .gainpill { font-size: 13px; padding: 5px 11px; }
.cs-none { color: var(--dim2, #8d81b3); font-size: 13px; font-style: italic; }
.cs-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 12px 0 16px; color: var(--dim); font-size: 12px; letter-spacing: 0.04em; }
.cs-stats b { color: var(--flame); font-weight: 700; }
