* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #eee; font: 15px/1.35 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#stage { position: fixed; inset: 0; touch-action: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
body.map #stage { background: #151a15; }
.bar { position: fixed; left: 0; right: 0; display: flex; gap: 6px; padding: 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); background: linear-gradient(rgba(0,0,0,.65), rgba(0,0,0,.35)); z-index: 5; }
#topbar { top: 0; padding-top: max(8px, env(safe-area-inset-top)); }
#bottombar { bottom: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,.65)); overflow-x: auto; }
.bar select { flex: 1; min-width: 0; }
button, select, input { font: inherit; color: #fff; background: rgba(40,40,40,.9); border: 1px solid #666; border-radius: 10px; padding: 9px 12px; }
input[type=number] { width: 4.2em; padding: 6px; }
input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; margin-right: 8px; }
button.active { background: #2f8cff; border-color: #2f8cff; }
button.primary { background: #ff3b30; border-color: #ff3b30; font-weight: bold; }
#bottombar button { flex: 1 0 auto; }
#banner { position: fixed; left: 8px; right: 8px; top: calc(62px + env(safe-area-inset-top)); z-index: 6; background: rgba(0,0,0,.78); border: 1px solid #ffd60a; color: #fff; padding: 10px 12px; border-radius: 12px; text-align: center; font-weight: 600; }
#banner .step { color: #ffd60a; }
#banner button { margin: 8px 4px 0; padding: 6px 12px; }
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(92vw, 460px); max-height: 82vh; overflow: auto; z-index: 10; background: rgba(20,20,20,.96); border: 1px solid #555; border-radius: 16px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.panel h1 { font-size: 21px; margin: 0 0 8px; } .panel h2 { font-size: 18px; margin: 0 0 8px; }
.panel label { display: block; margin: 10px 0; }
.panel > button { display: block; width: 100%; margin-top: 10px; }
.panel select { width: 100%; margin-top: 4px; }
.small { font-size: 13px; color: #bbb; }
#loupe { position: fixed; z-index: 8; width: 160px; height: 160px; border-radius: 50%; border: 3px solid #ffd60a; box-shadow: 0 4px 20px rgba(0,0,0,.7); pointer-events: none; top: calc(70px + env(safe-area-inset-top)); left: 12px; }
body.noui .bar, body.noui #banner, body.noui .panel { display: none !important; }
[hidden] { display: none !important; }

/* Calibration / adjust: hide the bars so every corner of the screen is tappable; banner sits mid-screen (over the table centre, not the corners). */
body.calib .bar { display: none; }
body.calib #banner { top: 50%; transform: translateY(-50%); left: 50%; right: auto; width: min(78vw, 420px); translate: -50% 0; background: rgba(0,0,0,.62); }

.kofi{display:inline-block;margin-top:8px;padding:8px 14px;border-radius:8px;background:#29abe0;color:#fff;text-decoration:none;font-weight:600}

/* v4 photo-first */
button.big { font-size: 18px; padding: 14px 12px; }
.tip { margin: 6px 0 2px; font-size: 14px; color: #ffd60a; text-align: center; }
.row2 { display: flex; gap: 8px; margin-top: 10px; } .row2 button { flex: 1; }
#fitBtn { position: fixed; right: 10px; top: calc(62px + env(safe-area-inset-top)); z-index: 7; padding: 6px 10px; font-size: 14px; background: rgba(0,0,0,.6); }
body.calib #fitBtn { top: calc(10px + env(safe-area-inset-top)); }
body.noui #fitBtn { display: none !important; }
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 12; background: rgba(0,0,0,.85); border: 1px solid #666; border-radius: 10px; padding: 8px 14px; max-width: 90vw; text-align: center; }
#version { color: #888; }
@media (orientation: landscape) and (max-height: 500px) {
  .bar { padding-top: 5px; padding-bottom: 5px; }
  button, select { padding: 6px 10px; }
  #bottombar { padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  .panel { max-height: 92vh; padding: 10px 14px; }
  #fitBtn { top: calc(48px + env(safe-area-inset-top)); }
  #banner { top: calc(48px + env(safe-area-inset-top)); }
}
/* Taps on the banner text go through to the picture; only its buttons catch them. */
body.calib #banner { pointer-events: none; }
body.calib #banner button, body.calib #banner a { pointer-events: auto; }
@media (max-width: 430px) { #bottombar { gap: 5px; } #bottombar button { padding: 9px 7px; font-size: 14px; } }
@media (orientation: landscape) and (max-height: 500px) {
  body.calib #banner { width: min(62vw, 460px); padding: 6px 10px; font-size: 13px; }
  body.calib #banner .small { display: none; }
  body.calib #banner button { margin-top: 4px; padding: 4px 10px; }
}
/* v6: compact calibrate/adjust banner, hidden while dragging a handle */
#banner .bmsg { line-height: 1.3; }
#banner .brow { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
#banner .brow button { margin: 6px 0 0; }
body.calib #banner { width: min(94vw, 440px); padding: 7px 10px; font-size: 14px; }
body.dragging #banner { opacity: 0; visibility: hidden; transition: opacity .12s; }
body.dragging #fitBtn { visibility: hidden; }
#banner.mini .bmsg, #banner.mini .small { display: none; }
#banner.mini .brow button { margin-top: 0; }
/* v7: pack selection */
.packBtn { display: block; width: 100%; margin-top: 10px; text-align: left; }
.packBtn .small { display: block; font-weight: normal; color: #fde; margin-top: 2px; }
.packBtn[data-pack="tftf"] { background: #2f6f4f; border-color: #2f6f4f; }
.packBtn.chosen { outline: 3px solid #ffd60a; }
.packline { margin: 4px 0 8px; } button.link { padding: 3px 10px; font-size: 13px; margin-left: 6px; }
body.welcome .bar { display: none; }
