/* Orbit Keep — one look: a storybook night sky over a tiny planet. Deep navy and violet, warm gold for money and
   action, parchment cards for the panel. Baloo 2 for everything, Cinzel Decorative for the title. */
:root {
  --ink: #0b1026; --ink2: #151b3d; --ink3: #1f2752; --line: rgba(255, 255, 255, .12);
  --text: #f2eee3; --dim: #aab0cf; --gold: #ffc94d; --gold2: #ffdd8a; --bad: #ff6b5b; --ok: #6be08a;
  --card: rgba(21, 27, 61, .92); --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --panel: 360px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font: 15px/1.4 'Baloo 2', system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
canvas#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; outline: none; }
input:focus, select:focus { border-color: var(--gold); }

.btn { border: 1px solid var(--line); background: var(--ink3); border-radius: 12px; padding: 9px 16px; font-weight: 700; transition: transform .08s, background .15s; }
.btn:hover { background: #2a3366; }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2b1d05; border-color: #ffe7a8; }
.btn.big { padding: 13px 18px; font-size: 17px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { background: #8a2b2b; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); }
#game.screen { display: block; padding: 0; pointer-events: none; }
#game.screen > * { pointer-events: auto; }

/* ---- menu ---- */
.title-card { width: min(460px, 100%); background: linear-gradient(180deg, rgba(21, 27, 61, .88), rgba(11, 16, 38, .92)); border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); display: grid; gap: 14px; }
h1 { margin: 0; font: 900 44px/1 'Cinzel Decorative', serif; letter-spacing: .02em; color: var(--gold2); text-shadow: 0 3px 0 #7a4b10, 0 0 30px rgba(255, 200, 80, .35); }
h1 span { color: #b9c8ff; text-shadow: 0 3px 0 #2a3a8a, 0 0 30px rgba(140, 170, 255, .35); }
.tag { margin: 0; color: var(--dim); }
.field { display: grid; gap: 4px; color: var(--dim); font-size: 13px; }
.field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.col { display: grid; gap: 10px; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .15em; text-align: center; }
.how summary { cursor: pointer; color: var(--gold2); font-weight: 700; }
.how ul { margin: 8px 0 0; padding-left: 18px; color: var(--dim); font-size: 14px; display: grid; gap: 6px; }

/* ---- setup / lobby ---- */
.setup { width: min(980px, 100%); max-height: 100%; overflow: auto; background: rgba(13, 18, 44, .92); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.setup header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.setup header h2 { flex: 1; margin: 0; font-size: 22px; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.picker-wrap { display: grid; gap: 8px; justify-items: center; }
#picker { width: 100%; max-width: 440px; aspect-ratio: 1; touch-action: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.slots { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.slots li { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.slots li.off { opacity: .55; }
.slots .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.slots select { padding: 5px 8px; font-size: 14px; }
.slots .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots .who small { color: var(--dim); font-weight: 500; }
.slots-wrap { display: grid; gap: 10px; align-content: start; }
.hint { color: var(--dim); font-size: 13px; margin: 0; }

/* ---- game HUD ---- */
.top { position: fixed; top: calc(8px + var(--sat)); left: 10px; right: calc(var(--panel) + 70px); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.chip { background: rgba(11, 16, 38, .78); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-weight: 700; white-space: nowrap; }
.chip.warn { border-color: var(--bad); color: #ffb3a8; }
.chip.dim { color: var(--dim); font-weight: 500; }
.gold { color: var(--gold2); }
.up { color: var(--ok); } .down { color: var(--bad); }
.players { display: flex; gap: 4px; margin-left: 4px; }
.players i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #10142a; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.players i.me { box-shadow: 0 0 0 2px var(--gold2); }
.players i.out { opacity: .3; text-decoration: line-through; }
.tools { position: fixed; top: calc(8px + var(--sat)); right: calc(var(--panel) + 12px); display: flex; flex-direction: column; gap: 6px; }
.ib { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: rgba(11, 16, 38, .8); font-size: 18px; }
.ib:hover { background: var(--ink3); }
.only-narrow { display: none; }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel); background: linear-gradient(180deg, rgba(16, 21, 50, .96), rgba(11, 16, 38, .97)); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding-top: var(--sat); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; border-radius: 10px; padding: 7px 4px; font-weight: 700; color: var(--dim); }
.tabs button.on { background: var(--ink3); color: var(--gold2); }
.pbody { flex: 1; overflow: auto; padding: 8px 10px calc(14px + var(--sab)); display: grid; gap: 8px; align-content: start; }
.card { background: rgba(255, 255, 255, .045); border: 1px solid var(--line); border-radius: 14px; padding: 9px 11px; transition: box-shadow .3s; }
.card.flash { box-shadow: 0 0 0 2px var(--gold); }
.card h4 { margin: 0; font-size: 15px; }
.card p { margin: 2px 0 6px; color: var(--dim); font-size: 13px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.act { border: 1px solid rgba(255, 201, 77, .35); background: rgba(255, 201, 77, .1); border-radius: 10px; padding: 5px 9px; font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.act:hover:not(:disabled) { background: rgba(255, 201, 77, .22); }
.act:disabled { opacity: .42; cursor: not-allowed; }
.act.locked { border-style: dashed; }
.act .cost { color: var(--gold2); font-size: 12px; }
.act .cost::before { content: '💰'; font-size: 10px; margin-right: 2px; }
.act.small { font-size: 12px; padding: 3px 8px; }
.act.big { flex: 1; flex-direction: column; padding: 10px; font-size: 15px; gap: 0; }
.act.big small { color: var(--dim); font-weight: 500; font-size: 12px; }
.sendrow { display: flex; gap: 8px; }
.prog { position: relative; height: 22px; border-radius: 8px; background: rgba(0, 0, 0, .35); overflow: hidden; flex: 1; min-width: 140px; }
.prog i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #4a7bd8, #7fd6ff); }
.prog span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 22px; font-weight: 700; }
.queue { display: flex; gap: 4px; width: 100%; }
.queue span { position: relative; width: 28px; height: 28px; border-radius: 8px; background: rgba(0, 0, 0, .3); display: grid; place-items: center; font-size: 15px; overflow: hidden; }
.queue span.now::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: var(--f); background: var(--gold); }
.selrow { display: grid; grid-template-columns: 1fr 30px 46px 30px; gap: 6px; align-items: center; width: 100%; }
.selrow button { border: 1px solid var(--line); background: var(--ink3); border-radius: 8px; height: 28px; font-weight: 800; }
.selrow b { text-align: center; }
.basehead { display: flex; align-items: center; justify-content: center; gap: 10px; }
.basehead button { border: 1px solid var(--line); background: var(--ink3); border-radius: 8px; width: 30px; height: 28px; }
.bad { color: var(--bad); } .ok { color: var(--ok); }
.lock { color: var(--dim); font-weight: 500; }
.empty { color: var(--dim); text-align: center; padding: 30px 10px; }

.toasts { position: fixed; left: 50%; top: calc(56px + var(--sat)); transform: translateX(calc(-50% - var(--panel) / 2)); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { background: rgba(11, 16, 38, .9); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; font-weight: 700; animation: pop .25s ease-out; }
.toast.bad { border-color: var(--bad); color: #ffcfc8; }
.toast.good { border-color: var(--ok); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.overlay { position: fixed; inset: 0; background: rgba(5, 8, 20, .7); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay .card { background: var(--ink2); padding: 22px; width: min(420px, 100%); text-align: center; display: grid; gap: 10px; }
.overlay .card.big { width: min(560px, 100%); }
.overlay h2 { margin: 0; font-size: 28px; color: var(--gold2); }
.stats { display: grid; gap: 4px; text-align: left; }
.stats div { display: grid; grid-template-columns: 16px 1fr auto auto; gap: 10px; align-items: center; font-size: 14px; }
.stats i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.netbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: #8a2b2b; border-radius: 10px; padding: 6px 14px; font-weight: 700; z-index: 20; }

/* ---- phones: the panel becomes a bottom sheet ---- */
@media (max-width: 760px), (max-height: 520px) and (max-width: 1000px) {
  :root { --panel: 0px; }
  .panel { top: auto; left: 0; width: auto; height: 46vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transition: transform .25s; }
  .panel.closed { transform: translateY(calc(100% - 46px)); }
  .tools { right: 10px; }
  .top { right: 64px; }
  .only-narrow { display: block; }
  .setup-grid { grid-template-columns: 1fr; }
  .toasts { transform: translateX(-50%); }
  h1 { font-size: 36px; }
}
@media (max-height: 520px) and (max-width: 1000px) {
  .panel { left: auto; right: 0; top: 0; bottom: 0; height: auto; width: 320px; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); }
  .panel.closed { transform: translateX(calc(100% - 0px)); }
  :root { --panel: 320px; }
  .tools { right: calc(var(--panel) + 10px); }
}
