/* ISLAND web client: sand / teal / driftwood. Mobile first (bottom sheet + tab bar); >= 900 px wide: a side panel. */
:root {
  --sand: #f7eedb; --sand2: #efe2c4; --sand3: #e2cd9c; --paper: #fbf6ea;
  --wood: #7a5a3c; --wood-d: #3e2c1e; --ink: #2f2519; --muted: #8a7960;
  --teal: #1b8584; --teal-d: #0f4f58; --teal-dd: #0a3a41; --sea: #2aa6a0; --foam: #d9f2ee;
  --coral: #d9573d; --palm: #4d9139; --sun: #eea92c; --violet: #8a5aa8; --blue: #3a7fc0;
  --r: 14px; --hdrH: 64px; --tabsH: 58px; --sheetH: 0px; --panelW: 420px;
  --safeB: env(safe-area-inset-bottom, 0px); --safeT: env(safe-area-inset-top, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--teal-dd); color: var(--ink); font: 14px/1.38 var(--font); -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#stage, #map2d { position: fixed; left: 0; right: 0; top: 0; bottom: 0; }
#stage { background: radial-gradient(ellipse at 50% 40%, #2c8f97 0%, #0f5763 60%, #0a3a41 100%); }
#map2d { z-index: 1; width: 100%; height: 100%; background: #0d4c57; touch-action: none; }

/* ---------------------------------------------------------------- header */
#hdr { position: fixed; z-index: 20; left: 0; right: 0; top: 0; padding: calc(6px + var(--safeT)) 10px 6px; color: #fff8e8;
  background: linear-gradient(180deg, rgba(10,58,65,.92), rgba(15,79,88,.78)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(0,0,0,.25); border-bottom: 2px solid rgba(226,205,156,.35); }
.hrow1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hday { font-weight: 800; font-size: 17px; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hclock { white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; font-weight: 700; opacity: .92; background: rgba(255,255,255,.1); padding: 1px 7px; border-radius: 8px; }
.chip.hpause { background: var(--sun); color: var(--ink); border-color: var(--sun); font-weight: 800; }
.hbtn { margin-left: auto; background: rgba(255,255,255,.12); border: 0; border-radius: 10px; width: 36px; height: 32px; color: #fff; font-size: 18px; flex: none; }
.hrow2 { display: flex; gap: 6px; margin-top: 5px; overflow-x: auto; scrollbar-width: none; }
.hrow2::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; background: rgba(247,238,219,.14); border: 1px solid rgba(247,238,219,.18); color: #fff8e8; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; }
.chip.budget { background: rgba(238,169,44,.22); border-color: rgba(238,169,44,.5); }
.chip.budget.hot { background: rgba(217,87,61,.4); }
.chip.conn { background: var(--coral); }
.chip.storm { background: rgba(217,87,61,.45); }

.menu { position: fixed; z-index: 40; background: var(--paper); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.35); padding: 6px; min-width: 200px; border: 1px solid var(--sand3); }
.menu button { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; }
.menu button:hover, .menu button:active { background: var(--sand2); }
#menu { top: calc(var(--hdrH) + 4px); right: 8px; }

/* ---------------------------------------------------------------- over the 3D */
#overlay { position: fixed; z-index: 15; left: 8px; right: 8px; top: calc(var(--hdrH) + 6px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
#banners, #toasts { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.banner { pointer-events: auto; max-width: 560px; width: 100%; border-radius: 12px; padding: 8px 12px; color: #fff; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.3); display: flex; gap: 8px; align-items: center; }
.banner small { font-weight: 500; opacity: .9; display: block; }
.banner .bi { font-size: 24px; }
.banner.ship { background: linear-gradient(90deg, #1b6f9a, #1b8584); animation: pulse 1.6s ease-in-out infinite; }
.banner.ship.dim { animation: none; background: rgba(15,79,88,.88); font-weight: 600; }
.banner.rescue { background: linear-gradient(90deg, #3f8a2f, #1b8584); }
.banner.voyage { background: linear-gradient(90deg, #6a4a2c, #1b6f9a); flex-wrap: wrap; }
.banner.storm { background: linear-gradient(90deg, #6b2f2f, #3a3a55); }
.banner.paused { background: rgba(62,44,30,.85); font-weight: 600; justify-content: center; padding: 5px 10px; width: auto; }
.banner .bprog { flex-basis: 100%; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.35), 0 4px 16px rgba(0,0,0,.3); } }
.toast { pointer-events: auto; max-width: 520px; width: 100%; background: rgba(251,246,234,.96); border-left: 5px solid var(--sun); border-radius: 10px; padding: 8px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.28); animation: tin .35s ease-out; font-size: 13.5px; }
.toast.t-big { border-color: var(--sun); font-weight: 700; }
.toast.t-death { border-color: #5a1c1c; background: rgba(40,24,20,.94); color: #ffe6dc; }
.toast.t-bad { border-color: var(--coral); }
.toast.t-good { border-color: var(--palm); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .4s; }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }

#mapBtns { position: fixed; z-index: 12; right: 10px; bottom: calc(var(--tabsH) + var(--safeB) + var(--sheetH) + 28px); display: flex; flex-direction: column; gap: 6px; transition: bottom .25s; }
#mapBtns button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(247,238,219,.25); background: rgba(10,58,65,.78); color: #fff8e8; font-size: 17px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.25); padding: 0; }
#mapBtns button.on { background: var(--sun); color: var(--ink); }
body.sheet-full #mapBtns, body.sheet-half #mapBtns button:nth-child(n+5) { display: none; }
#selChip { position: fixed; z-index: 12; left: 10px; right: 60px; bottom: calc(var(--tabsH) + var(--safeB) + var(--sheetH) + 28px); max-width: 420px; background: rgba(251,246,234,.97); border-radius: 12px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,.3); display: flex; gap: 8px; align-items: center; transition: bottom .25s; }
#selChip .nm { font-weight: 800; }
#selChip .dt { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#selChip .grow { flex: 1; min-width: 0; }
body.sheet-full #selChip { display: none; }
#playPill { position: fixed; z-index: 13; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabsH) + var(--safeB) + var(--sheetH) + 64px); background: var(--sun); color: var(--ink); border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,.3); animation: pulse 1.4s infinite; }

/* ---------------------------------------------------------------- panel: phone = bottom sheet */
#panel { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; background: var(--sand); box-shadow: 0 -4px 20px rgba(0,0,0,.25); border-radius: 18px 18px 0 0; }
#grab { height: 18px; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; flex: none; }
#grab span { width: 44px; height: 5px; border-radius: 3px; background: var(--sand3); }
#pbody { height: var(--sheetH); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; transition: height .25s; }
#pbody > section { display: none; padding: 4px 12px 16px; }
#pbody > section.on { display: block; }
body.sheet-closed #grab { height: 14px; }
#tabs { flex: none; display: flex; height: calc(var(--tabsH) + var(--safeB)); padding-bottom: var(--safeB); background: var(--paper); border-top: 1px solid var(--sand3); }
#tabs button { flex: 1; min-width: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); position: relative; padding: 0; }
#tabs button b { font-size: 19px; font-weight: 400; line-height: 1.1; filter: grayscale(.4); }
#tabs button span { font-size: 11px; font-weight: 700; }
#tabs button.on { color: var(--teal-d); }
#tabs button.on b { filter: none; transform: scale(1.1); }
#tabs button.on::after { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal); }
#tabs .dot { position: absolute; top: 7px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
#tabs .more { display: none; }
#moreMenu { right: 6px; bottom: calc(var(--tabsH) + var(--safeB) + 6px); }

@media (max-width: 899px) { body.sheet-full #banners { display: none; } }

/* ---------------------------------------------------------------- panel: desktop = side panel */
@media (min-width: 900px) {
  :root { --hdrH: 58px; }
  #stage, #map2d { right: var(--panelW); top: 0; }
  #map2d { width: calc(100% - var(--panelW)); }
  #hdr { right: var(--panelW); }
  .hrow1 { float: left; margin-right: 12px; } .hrow2 { margin-top: 3px; }
  .hbtn { margin-left: 10px; }
  #panel { top: 0; left: auto; width: var(--panelW); border-radius: 0; flex-direction: column-reverse; justify-content: flex-end; border-left: 2px solid var(--sand3); }
  #grab { display: none; }
  #pbody { height: auto !important; flex: 1; }
  #tabs { height: auto; padding: 6px 4px 0; flex-wrap: wrap; border-top: 0; border-bottom: 1px solid var(--sand3); background: var(--sand2); }
  #tabs button { flex: 1 0 22%; flex-direction: row; gap: 5px; height: 38px; border-radius: 10px 10px 0 0; }
  #tabs button span { font-size: 12.5px; }
  #tabs button.on { background: var(--sand); }
  #tabs button.on::after { top: auto; bottom: 0; display: none; }
  #tabs .more { display: flex; }
  #tabs .more[hidden] { display: none; }
  #tabs .morebtn { display: none; }
  #mapBtns { right: calc(var(--panelW) + 12px); bottom: 14px; }
  #selChip { left: 12px; right: auto; width: 380px; bottom: 14px; }
  #playPill { left: calc(50% - var(--panelW) / 2); bottom: 70px; }
  #overlay { right: calc(var(--panelW) + 8px); }
  body.sheet-half #mapBtns button:nth-child(n+5), body.sheet-full #mapBtns, body.sheet-full #selChip { display: flex; }
  #menu { right: calc(var(--panelW) + 8px); }
}

/* ---------------------------------------------------------------- content */
h3 { margin: 12px 2px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--wood); display: flex; align-items: center; gap: 6px; }
h3 .r { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--muted); }
.card { background: var(--paper); border-radius: var(--r); padding: 10px 12px; margin: 8px 0; box-shadow: 0 1px 0 var(--sand3), 0 2px 8px rgba(62,44,30,.06); border: 1px solid rgba(226,205,156,.6); }
.card.tap { cursor: pointer; }
.card.tap:active { transform: scale(.99); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.big { font-size: 20px; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.kv > :nth-child(odd) { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--sand2); color: var(--wood-d); white-space: nowrap; }
.pill.red { background: #f6d2c8; color: #8a2412; }
.pill.green { background: #d8ebcf; color: #2b5a1f; }
.pill.teal { background: var(--foam); color: var(--teal-d); }
.pill.gold { background: #f7e2b0; color: #7a4f0a; }
.pill.grey { background: #e6e0d4; color: #6a5f50; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.btn { border: 0; border-radius: 10px; padding: 8px 12px; background: var(--teal); color: #fff; font-weight: 700; }
.btn.alt { background: var(--sand2); color: var(--wood-d); border: 1px solid var(--sand3); }
.btn.warn { background: var(--coral); }
.btn.gold { background: var(--sun); color: var(--ink); }
.btn.on { background: var(--teal-d); color: #fff; box-shadow: inset 0 0 0 2px var(--sun); }
.btn:disabled { opacity: .5; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btns .btn { flex: 1 0 auto; }
input[type=text], input[type=password], input[type=number] { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--sand3); background: #fff; min-width: 0; }

/* bars */
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; }
.bar { display: grid; grid-template-columns: 76px 1fr 26px; align-items: center; gap: 5px; font-size: 11.5px; }
.bar .bl { color: var(--muted); white-space: nowrap; }
.bar .bt { height: 7px; background: var(--sand2); border-radius: 4px; overflow: hidden; }
.bar .bf { height: 100%; border-radius: 4px; transition: width .4s; }
.bar .bv { text-align: right; font-variant-numeric: tabular-nums; color: var(--wood-d); font-weight: 700; }
.pbar { height: 9px; background: var(--sand2); border-radius: 5px; overflow: hidden; margin: 4px 0; }
.pbar > i { display: block; height: 100%; background: var(--teal); border-radius: 5px; transition: width .4s; }
.banner .pbar { background: rgba(255,255,255,.25); } .banner .pbar > i { background: #fff; }

/* survivor cards */
.sv .hd { display: flex; align-items: center; gap: 8px; }
.av { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; border: 3px solid; background: var(--sand); position: relative; }
.av .crown { position: absolute; top: -12px; right: -6px; font-size: 16px; }
.sv .nm { font-weight: 800; font-size: 15.5px; }
.sv .md { font-size: 12px; color: var(--muted); }
.sv .doing { font-size: 13px; margin-top: 6px; }
.sv .doing .wh { color: var(--muted); }
.sv .say { font-size: 12.5px; font-style: italic; color: var(--wood); margin-top: 3px; }
.sv.dead { background: #ece5d6; border-style: dashed; }
.sv.dead .av { filter: grayscale(1); }
.sv.sel { box-shadow: 0 0 0 2px var(--teal); }
.carry { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* camp */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 > .card { margin: 0; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }
.items { display: flex; flex-wrap: wrap; gap: 5px; }
.item { background: var(--sand); border: 1px solid var(--sand3); border-radius: 9px; padding: 2px 7px; font-size: 12.5px; white-space: nowrap; }
.item b { font-variant-numeric: tabular-nums; }
.water3 { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--sand2); margin: 6px 0 4px; }
.water3 > i { display: block; height: 100%; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 3px; }

/* escape */
.route .hd { display: flex; align-items: center; gap: 8px; }
.route .ic { font-size: 26px; }
.route .odds { margin-left: auto; text-align: right; }
.route .odds b { font-size: 22px; color: var(--teal-d); display: block; line-height: 1; }
.route .odds span { font-size: 11px; color: var(--muted); }
.check { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-top: 6px; }
.check span.no { color: var(--muted); }
.islet { display: flex; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--sand3); }
.islet:first-child { border-top: 0; }

/* feed / diary */
.feed { list-style: none; margin: 0; padding: 0; }
.fe { padding: 6px 8px 6px 10px; border-left: 4px solid var(--sand3); margin: 4px 0; background: var(--paper); border-radius: 0 10px 10px 0; font-size: 13.5px; }
.fe .tm { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.fe.big { border-color: var(--sun); background: #fdf0cf; font-weight: 700; font-size: 14.5px; }
.fe.death { border-color: #4a1712; background: #3a2520; color: #ffe8e0; font-weight: 700; }
.fe.death .tm { color: #d9b8a8; }
.fe.bad { border-color: var(--coral); }
.fe.good { border-color: var(--palm); }
.fe.social { border-color: var(--violet); }
.fe.talk { border-color: var(--teal); color: #2b4a4a; }
.fe.tide { border-color: var(--blue); }
.fe.discover { border-color: #c08a1a; background: #fbf1d8; }
.fe.warn { border-color: #e07b1a; background: #fcebd9; }
.fe.story { border-color: var(--wood); font-style: italic; }
.fe.haul { border-color: #d8ccb0; color: #7a6e5a; font-size: 12.5px; padding: 3px 8px; background: transparent; }
.fe.system { border-color: #b9b1a2; color: #6a6254; font-size: 12.5px; }
.filt { display: flex; gap: 5px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.filt button { flex: none; border: 1px solid var(--sand3); background: var(--paper); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; }
.filt button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.di .who { font-weight: 800; }
.di .tx { white-space: pre-wrap; margin-top: 4px; font-family: Georgia, "Iowan Old Style", serif; font-size: 14px; color: #3a2e22; }

/* modal / sheet */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,30,34,.55); display: flex; align-items: flex-end; justify-content: center; }
.mcard { position: relative; background: var(--sand); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px 14px calc(18px + var(--safeB)); box-shadow: 0 -6px 30px rgba(0,0,0,.35); animation: up .25s ease-out; }
.mcard.small { max-width: 440px; }
.mclose { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--sand2); font-size: 16px; z-index: 2; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@media (min-width: 700px) { .modal { align-items: center; } .mcard { border-radius: 20px; max-height: 86vh; } }
.dhead { display: flex; gap: 12px; align-items: center; padding-right: 36px; }
.dhead .av { width: 58px; height: 58px; font-size: 32px; }
.rel { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px dashed var(--sand3); font-size: 13px; }
.rel:first-child { border-top: 0; }
.rel .rb { width: 80px; height: 7px; border-radius: 4px; background: var(--sand2); position: relative; overflow: hidden; flex: none; }
.rel .rb i { position: absolute; top: 0; bottom: 0; left: 50%; }
.mem { font-size: 13px; padding: 4px 0; border-top: 1px dashed var(--sand3); }
.mem:first-child { border-top: 0; }
.chat { font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--sand3); }
.chat p { margin: 2px 0; }

/* ended */
.mcard.ended { text-align: center; }
.ended .oc { font-size: 54px; }
.ended h2 { margin: 4px 0; }

/* boot */
#boot { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 45%, #2aa6a0, #0f4f58 70%); color: #fff8e8; font-weight: 700; transition: opacity .5s; }
#boot.gone { opacity: 0; pointer-events: none; }
.bootcard { text-align: center; }
.bootlogo { font-size: 64px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
