/* ================= Interface: frosted light panels along the top; the floor stays clear ================= */
:root {
  --ink: #15161a;
  --ink-2: rgba(21, 22, 26, .62);
  --ink-3: rgba(21, 22, 26, .38);
  --panel: rgba(255, 255, 255, .7);
  --panel-solid: rgba(252, 252, 251, .97);
  --edge: rgba(255, 255, 255, .75);
  --hair: rgba(21, 22, 26, .08);
  --hover: rgba(21, 22, 26, .055);
  --accent: #ff3b4f;
  --tip: rgba(21, 22, 26, .92);
  --shadow: 0 1px 1px rgba(15, 16, 22, .04), 0 6px 16px -4px rgba(15, 16, 22, .1), 0 18px 40px -12px rgba(15, 16, 22, .14);
  --r: 16px;
  --h: 50px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
}

.panel {
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--edge);
  backdrop-filter: blur(22px) saturate(1.8);
  -webkit-backdrop-filter: blur(22px) saturate(1.8);
  color: var(--ink);
  border-radius: var(--r);
}

#topleft, #topbar { position: absolute; top: 14px; display: flex; gap: 8px; pointer-events: auto; align-items: flex-start; z-index: 3; }
#topleft { left: 14px; }
#topbar { right: 14px; }

button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- tooltips: [data-tip] shows a small dark label under the button */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 10px); left: 50%; transform: translate(-50%, -4px) scale(.96); padding: 6px 10px; border-radius: 9px; background: var(--tip); color: #fff; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .14s, transform .14s; z-index: 10; }
@media (hover: hover) { [data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0) scale(1); transition-delay: .2s; } }
.open[data-tip]::after { display: none; }
/* buttons at the screen edges: the label lines up with the button instead of running off the screen */
.spawn-add[data-tip]::after { left: 0; transform: translate(0, -4px) scale(.96); transform-origin: left top; }
@media (hover: hover) { .spawn-add[data-tip]:hover::after { transform: translate(0, 0) scale(1); } }
.btn-group .anchor:last-child [data-tip]::after, #btn-settings[data-tip]::after { left: auto; right: 0; transform: translate(0, -4px) scale(.96); transform-origin: right top; }
@media (hover: hover) { #btn-settings[data-tip]:hover::after { transform: translate(0, 0) scale(1); } }

/* ---- shared button base: soft square that fills on hover, inks in when active */
.slot, .spawn-b, .icon-btn, .spawn-add { flex: 0 0 auto; width: 42px; height: 42px; border: none; border-radius: 12px; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; transition: background .16s, color .16s, transform .12s, box-shadow .16s; }
.slot:hover, .spawn-b:hover, .icon-btn:hover { background: var(--hover); color: var(--ink); }
.slot:active, .spawn-b:active, .icon-btn:active, .spawn-add:active { transform: scale(.9); }
.slot svg { width: 22px; height: 22px; }
/* icons are grey snapshots, sized in icons.js */
.slot img { pointer-events: none; user-select: none; transition: transform .14s, filter .14s; }
.slot:hover img { transform: scale(1.05); filter: brightness(.82); }
.slot.active img { filter: brightness(.62); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active, .icon-btn.open { background: var(--ink); color: #fff; box-shadow: 0 6px 14px -4px rgba(15, 16, 22, .45); }
/* the chosen weapon sits on a white card with a soft edge and a darker icon */
.slot.active { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(21, 22, 26, .16), 0 1px 2px rgba(15, 16, 22, .1), 0 5px 12px -3px rgba(15, 16, 22, .22); }

/* ---- spawn (top left) */
.spawn { display: flex; align-items: center; gap: 2px; padding: 4px; height: var(--h); }
.spawn-add { background: var(--ink); color: #fff; margin-right: 4px; box-shadow: 0 6px 14px -4px rgba(15, 16, 22, .45); }
.spawn-add svg { width: 20px; height: 20px; }
.spawn-add:hover { background: #2a2b31; }
.spawn-b { color: var(--ink); }
.spawn-b svg { width: 25px; height: 25px; }
.spawn-b.active { background: var(--hover); }
.spawn-b.active::before { content: ''; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }

/* ---- weapon bar (top centre) */
#dock { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 2; max-width: calc(100% - 16px); transition: top .2s; }
.strip { pointer-events: auto; display: flex; align-items: center; height: var(--h); padding: 4px; max-width: 100%; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.grp { display: flex; gap: 1px; }
.grp + .grp { margin-left: 5px; padding-left: 5px; box-shadow: inset 1px 0 0 var(--hair); }
.caption { pointer-events: none; display: flex; gap: 8px; align-items: baseline; padding: 6px 13px; border-radius: 999px; font-size: 12px; color: var(--ink-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.caption:empty { display: none; }
.caption b { color: var(--ink); font-weight: 650; }
.caption.pop-in { animation: popin .22s ease-out; }
@keyframes popin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.options { pointer-events: auto; display: none; gap: 2px; padding: 4px; border-radius: 999px; flex-wrap: wrap; justify-content: center; }
.options.on { display: flex; }
.chip { border: none; border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600; background: transparent; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; }
.chip:hover { background: var(--hover); color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; }

/* ---- controls (top right) */
.btn-group { display: flex; gap: 2px; padding: 4px; height: var(--h); align-items: center; }
.room-btn { height: var(--h); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; border: none; cursor: pointer; color: var(--ink); transition: background .15s; }
.room-btn:hover, .room-btn.open { background: var(--panel-solid); }
.room-btn b { display: none; }
.room-dot { display: block; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(21, 22, 26, .12); }
.chev { display: grid; place-items: center; color: var(--ink-3); }
.chev svg { width: 15px; height: 15px; }

/* ---- popovers */
.anchor { position: relative; }
.pop { position: absolute; top: calc(100% + 10px); width: min(320px, calc(100vw - 24px)); max-height: calc(100vh - 100px); overflow-y: auto; padding: 6px 14px 14px; background: var(--panel-solid); opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; pointer-events: none; transition: opacity .16s, transform .16s; z-index: 6; scrollbar-width: none; }
.anchor.left .pop { left: 0; transform-origin: top left; }
.anchor.right .pop { right: 0; }
.btn-group .anchor.right .pop { right: -4px; }
.pop.on { opacity: 1; transform: none; pointer-events: auto; }
.sec { margin: 13px 0 7px; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.note { margin-top: 12px; font-size: 11px; color: var(--ink-3); line-height: 1.5; }

.room-list { display: flex; flex-direction: column; gap: 2px; }
.room-item { display: flex; align-items: center; gap: 12px; padding: 7px; border: none; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background .15s; }
.room-item:hover { background: var(--hover); }
.room-item.active { background: var(--hover); box-shadow: inset 0 0 0 1.5px var(--ink); }
.room-item i { flex: 0 0 52px; height: 38px; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(21, 22, 26, .12); }
.room-item span { display: flex; flex-direction: column; gap: 2px; }
.room-item b { font-size: 13px; font-weight: 650; }
.room-item small { font-size: 11px; color: var(--ink-2); line-height: 1.35; }

.seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--hover); }
.seg-b { flex: 1 1 0; border: none; background: transparent; padding: 7px 4px; border-radius: 9px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.seg-b:hover { color: var(--ink); }
.seg-b.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 16, 22, .12), 0 2px 8px -2px rgba(15, 16, 22, .12); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13px; cursor: pointer; }
.row + .row { border-top: 1px solid var(--hair); }
.row .lbl { flex: 1; }
.row input[type=range] { width: 130px; accent-color: var(--ink); }
.switch { appearance: none; -webkit-appearance: none; flex: 0 0 36px; width: 36px; height: 21px; border-radius: 999px; background: rgba(21, 22, 26, .14); position: relative; cursor: pointer; transition: background .18s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(15px); }
.text-btn { margin-top: 12px; width: 100%; padding: 10px; border: none; border-radius: 11px; background: var(--hover); color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.text-btn:hover { background: rgba(21, 22, 26, .1); }

/* ---- pause + first-run hint */
.pausetag { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 16px 30px; font-size: 18px; font-weight: 700; letter-spacing: .06em; text-align: center; display: none; pointer-events: none; }
.pausetag.on { display: block; }
.pausetag span { display: block; font-size: 12px; font-weight: 500; letter-spacing: .01em; margin-top: 6px; color: var(--ink-2); }
.hint { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; transition: opacity 1s; }
.hint.hide { opacity: 0; }

/* immersive mode: every panel steps out of the way; U (or a tap in the top-right corner on a touch screen) brings them back */
#ui { transition: opacity .25s; }
body.immersive #ui { opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }
.toast { position: fixed; z-index: 20; }
.ui-back { display: none; position: fixed; top: 0; right: 0; width: 64px; height: 64px; padding: 0; border: none; background: transparent; z-index: 20; }
@media (pointer: coarse) { body.immersive .ui-back { display: block; } }

/* not enough room for one row: the weapon bar drops just below the side panels (set by ui.js) */
#ui.stack #dock { top: 74px; }

@media (max-width: 760px) {
  :root { --h: 44px; }
  #topleft { left: 8px; top: 8px; }
  #topbar { right: 8px; top: 8px; gap: 6px; }
  .slot, .spawn-b, .icon-btn, .spawn-add { width: 36px; height: 36px; border-radius: 10px; }
  .slot img { width: 30px; height: auto; }
  .spawn-b svg { width: 22px; height: 22px; }
  .room-btn b, .room-btn .chev { display: none; }
  .room-btn { padding: 0 7px; }
  #ui.stack #dock, #dock { top: 60px; width: calc(100% - 16px); }
  .strip { overflow-x: auto; }
  /* a blurred panel becomes the anchor of anything fixed inside it, so the buttons that open full-width popups go solid */
  .btn-group, .room-btn { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--panel-solid); }
  .options { border-radius: 22px; }
  .pop { position: fixed; left: 8px !important; right: 8px !important; top: 60px; width: auto !important; }
  .hint { white-space: normal; text-align: center; border-radius: 14px; font-size: 12px; }
  [data-tip]::after { display: none; }
}

/* phones: the spawn buttons and the controls would overlap on one row, so the controls drop to a second row */
@media (max-width: 520px) {
  #topbar { left: 8px; right: 8px; top: 58px; justify-content: space-between; }
  #topleft { max-width: calc(100% - 16px); }
  .spawn { max-width: 100%; }
  #ui.stack #dock, #dock { top: 108px; }
  .pop { top: 108px; }
  .hint { bottom: 12px; }
}
@media (max-width: 520px) and (max-height: 520px) { /* a phone on its side: keep the floor visible */
  .hint { display: none; }
}
