/* World Horizons UI: portrait first on every device. On wide screens the game sits in a centred portrait column. */
:root {
  --bg: #070b18; --card: rgba(16, 22, 44, .92); --card2: rgba(26, 36, 66, .95); --line: rgba(255,255,255,.1);
  --text: #eef2ff; --muted: #9aa6c8; --accent: #62a8ff; --accent2: #a777ff; --good: #5cdb9b; --warn: #ff9f73;
  --r: 18px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: radial-gradient(ellipse at top, #1b2350 0%, #070b18 60%); color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; touch-action: none; user-select: none; }
#stage { position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100vw, calc(100dvh * 0.6)); height: 100dvh; overflow: hidden; background: var(--bg);
  box-shadow: 0 0 80px rgba(0,0,0,.6); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
button { font: inherit; color: var(--text); border: 1px solid var(--line); background: linear-gradient(180deg, #1c2852, #141c3a);
  border-radius: 14px; padding: 11px 14px; cursor: pointer; touch-action: manipulation; }
button:active { transform: scale(.97); filter: brightness(1.2); }
button:disabled { opacity: .45; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 700; }
input, select { font: inherit; color: var(--text); background: rgba(5,8,20,.9); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; width: 100%; outline: none; }
input:focus { border-color: var(--accent); }
.hidden { display: none !important; }

/* top bar */
.top { position: absolute; left: 0; right: 0; top: 0; padding: calc(8px + var(--safe-t)) 10px 0; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.row { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; }
.chip { pointer-events: auto; background: rgba(10, 14, 32, .82); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); white-space: nowrap; }
.chip.cash { color: #ffe08a; }
.needs { display: flex; gap: 4px; pointer-events: auto; }
.need { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 15px;
  background: conic-gradient(var(--c, #5cdb9b) var(--p, 100%), rgba(255,255,255,.08) 0); position: relative; }
.need::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: rgba(10,14,32,.92); z-index: 0; }
.need span { position: relative; z-index: 1; }

/* bottom */
.bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; pointer-events: auto; }
.nav button { padding: 9px 2px 7px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; background: rgba(12,18,40,.88); }
.nav button b { font-size: 19px; line-height: 1; }
.actions { display: flex; justify-content: center; gap: 8px; pointer-events: none; min-height: 46px; }
.actions button { pointer-events: auto; }
.prompt { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; font-weight: 700; padding: 12px 20px; border-radius: 999px; box-shadow: 0 6px 20px rgba(98,168,255,.35); }

/* joystick */
.joy { position: absolute; left: 18px; bottom: calc(150px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); touch-action: none; }
.joy i { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.25); }
.side-btns { position: absolute; right: 12px; bottom: calc(160px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.side-btns button { width: 58px; height: 58px; border-radius: 50%; padding: 0; font-size: 12px; font-weight: 700; background: rgba(12,18,40,.85); }

/* sheets (menus), dialogs, toasts */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72%; display: flex; flex-direction: column;
  background: var(--card); border-top: 2px solid rgba(98,168,255,.4); border-radius: 26px 26px 0 0; padding: 8px 14px calc(14px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30%); opacity: 0; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 4px auto 10px; }
.sheet h2 { margin: 0 0 10px; font-size: 19px; }
.sheet .list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; touch-action: pan-y; }
.sheet .list button { text-align: left; padding: 13px 14px; }
.sheet .list .info { color: var(--muted); font-size: 13px; padding: 2px 4px; }
.sheet .close { margin-top: 10px; }
.dialog { position: absolute; left: 6%; right: 6%; top: 50%; transform: translateY(-50%); background: var(--card2); border: 1px solid var(--line);
  border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 10px; }
.toasts { position: absolute; left: 0; right: 0; top: calc(108px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 60; }   /* messages always on top */
.toast { max-width: 86%; background: rgba(8,12,28,.92); border: 1px solid var(--line); padding: 9px 14px; border-radius: 14px; font-size: 13.5px; text-align: center; animation: fade 3.6s forwards; }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.progress { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); z-index: 40; width: 78%; background: rgba(8,12,28,.92);
  border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* full screens: loading, account, creator */
.screen { position: absolute; inset: 0; overflow-y: auto; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: radial-gradient(ellipse at 20% 0%, #2a2d7a 0%, transparent 55%), radial-gradient(ellipse at 90% 100%, #0e5560 0%, transparent 50%), var(--bg);
  display: flex; flex-direction: column; gap: 14px; touch-action: pan-y; }
.logo { text-align: center; margin-top: 4vh; }
.logo h1 { margin: 0; font-size: 34px; letter-spacing: 1px; text-shadow: 0 4px 30px rgba(98,168,255,.6); }
.logo p { margin: 4px 0 0; color: var(--accent); letter-spacing: 4px; font-weight: 700; font-size: 13px; }
.tag { text-align: center; color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 38px; height: 38px; border-radius: 50%; padding: 0; border: 3px solid transparent; }
.swatches button.on { border-color: #fff; }
.msg { color: var(--warn); font-size: 13px; min-height: 18px; }
.small { color: var(--muted); font-size: 12px; }
.preview { height: 34vh; min-height: 220px; border-radius: 22px; overflow: hidden; background: radial-gradient(circle at 50% 70%, #24305e, #0b1022); }
.loading { justify-content: center; align-items: center; }
.loading .bar { width: 70%; }

/* full-screen map */
.mapPanel { position: absolute; inset: 0; background: rgba(7, 11, 24, .97); display: flex; flex-direction: column; gap: 10px;
  padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); animation: up .2s ease-out; }
.mapPanel canvas { width: 100%; aspect-ratio: 1; border-radius: 18px; touch-action: none; background: #3d5a3a; }
.mapPanel .list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; touch-action: pan-y; }
.mapPanel .list button { text-align: left; }
.chip.dest { color: #9fd3ff; }

/* 3D map */
.map3d { position: absolute; inset: 0; pointer-events: none; }
.map3d > * { pointer-events: auto; }
.map3d .bar { position: absolute; left: 10px; right: 10px; top: calc(10px + var(--safe-t)); display: flex; gap: 8px; align-items: center; }
.map3d .bar h2 { margin: 0; flex: 1; text-shadow: 0 2px 8px #000; }
.map3d .pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pin { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; display: flex; flex-direction: column; align-items: center; }
.pin b { width: 38px; height: 38px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center;
  background: #62a8ff; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.5); }
.pin b span { transform: rotate(45deg); font-size: 17px; }
.pin.sel b { background: #ffd166; } .pin.home b { background: #ffb703; } .pin.me b { background: #4fd1ff; border-radius: 50%; }
.pin i { margin-top: 4px; font-style: normal; font-size: 11px; font-weight: 700; background: rgba(8,12,28,.85); padding: 2px 7px; border-radius: 8px; white-space: nowrap; }
.map3d .sheetbox { position: absolute; left: 0; right: 0; bottom: 0; max-height: 42%; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 12px calc(12px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.map3d .sheetbox .list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; touch-action: pan-y; }
.map3d .sheetbox .list button { text-align: left; padding: 10px 12px; }
.mapmode .top, .mapmode .bottom, .mapmode .joy, .mapmode .side-btns { display: none !important; }
/* chat */
.chatlog { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 34vh; touch-action: pan-y; }
.chatlog div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 7px 10px; font-size: 13.5px; }
.chatlog div b { color: var(--accent); }
.chatrow { display: flex; gap: 6px; }
.need { cursor: pointer; }
.chip { cursor: pointer; }
.toast.whisper { background: linear-gradient(135deg, rgba(60,20,90,.95), rgba(20,10,40,.95)); border-color: #b48cff; color: #e9dcff; font-style: italic; }
.progressrow { display: flex; flex-direction: column; gap: 4px; background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 10px; font-size: 13.5px; }
.progressrow.done { opacity: .6; }
.map3d .cross { position: absolute; left: 50%; width: 46px; height: 46px; transform: translate(-50%, -50%); pointer-events: none; }
.map3d .cross::before, .map3d .cross::after { content: ""; position: absolute; background: #ffd166; box-shadow: 0 0 6px #000; }
.map3d .cross::before { left: 21px; top: 0; width: 4px; height: 46px; } .map3d .cross::after { top: 21px; left: 0; width: 46px; height: 4px; }
.map3d .cross i { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; border: 3px solid #ffd166; border-radius: 50%; }
.toast.news { background: linear-gradient(135deg, rgba(20,60,120,.96), rgba(10,24,60,.96)); border-color: #62a8ff; font-weight: 600; }
.nav button small { font-size: 11px; }
.newsitem { background: rgba(255,255,255,.05); border-radius: 12px; padding: 9px 11px; font-size: 13.5px; display: flex; gap: 8px; }
.newsitem.unread { border-left: 3px solid #62a8ff; }
.newsitem b { font-size: 18px; }

/* the shift task card sits above the "Working..." bar; messages stay at the top, above everything */
.dialog { z-index: 50; }
/* compact shift task card: fits between the messages (top) and the "Working..." bar (bottom) */
.taskcard { padding: 10px 12px !important; gap: 6px !important; max-height: 42vh; overflow-y: auto; }
.taskcard b { font-size: 14px; }
.taskcard button { padding: 8px 10px; font-size: 13.5px; min-height: 0; }
.taskcard .small { font-size: 11.5px; }
