:root {
  --bg: #2b8fd8;
  --ink: #1d2433;
  --ink2: #5a6478;
  --card: #ffffff;
  --glass: rgba(20, 26, 40, 0.62);
  --glass2: rgba(20, 26, 40, 0.78);
  --accent: #ffb81f;
  --accent-ink: #3b2a00;
  --green: #2fb35a;
  --red: #e2413b;
  --blue: #2f6fd6;
  --radius: 14px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --head: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
canvas#game { position: fixed; inset: 0; display: block; }
canvas#overlay { position: fixed; inset: 0; display: block; pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; user-select: text; -webkit-user-select: text; }

.btn { border-radius: 12px; padding: 10px 16px; font-weight: 700; background: #eef1f6; color: var(--ink); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #d18f00; }
.btn.green { background: var(--green); color: #fff; box-shadow: 0 3px 0 #1f8a42; }
.btn.ghost { background: transparent; border: 2px solid #dfe4ec; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; font-family: var(--head); letter-spacing: .3px; }
.btn:disabled { opacity: .5; filter: grayscale(1); }

/* ------------------------------------------------ auth */
#auth { position: fixed; inset: 0; display: grid; place-items: center; overflow: auto; padding: 16px; z-index: 50; touch-action: pan-y; }
#authBg { position: fixed; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); filter: blur(3px) saturate(1.1); animation: pan 60s ease-in-out infinite alternate; object-fit: cover; }
@keyframes pan { from { transform: scale(1.3) translate(-4%, -3%); } to { transform: scale(1.3) translate(4%, 3%); } }
.auth-card { position: relative; width: min(420px, 100%); background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-radius: 24px; padding: 22px 22px 16px; box-shadow: 0 20px 60px rgba(0,30,60,.35); text-align: center; }
.logo { font-size: 46px; line-height: 1; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(4deg); } }
h1 { font-family: var(--head); font-size: 34px; margin: 4px 0 2px; color: #1f7a3a; letter-spacing: .5px; }
.tagline { margin: 0 0 10px; color: var(--ink2); font-size: 14px; }
.pill { display: inline-block; background: #e9f8ee; color: #1f7a3a; border-radius: 99px; padding: 5px 12px; font-weight: 700; font-size: 13px; margin-bottom: 12px; }
.tabs { display: flex; background: #eef1f6; border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--ink2); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
#authForm { text-align: left; display: flex; flex-direction: column; gap: 6px; }
#authForm label { font-weight: 700; font-size: 13px; margin-top: 4px; }
#authForm label small { font-weight: 500; color: var(--ink2); }
#authForm input { width: 100%; padding: 12px; border: 2px solid #dfe4ec; border-radius: 12px; outline: none; font-size: 16px; background: #fff; }
#authForm input:focus { border-color: var(--accent); }
.at-input { display: flex; align-items: center; border: 2px solid #dfe4ec; border-radius: 12px; background: #fff; }
.at-input:focus-within { border-color: var(--accent); }
.at-input span { padding-left: 12px; font-weight: 800; color: var(--ink2); }
.at-input input { border: 0 !important; padding-left: 4px !important; }
.perks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0 6px; }
.perks span { background: #fff6e0; border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: #7a5300; }
.error { color: var(--red); font-weight: 700; font-size: 13px; min-height: 18px; text-align: center; }
.gender { display: flex; gap: 8px; }
.gender button { flex: 1; padding: 10px; border: 2px solid #dfe4ec; border-radius: 12px; background: #fff; font-weight: 800; color: var(--ink2); }
.gender button.on { border-color: var(--accent); background: #eaf7ee; color: var(--ink); }
.nb-note { margin-top: 6px; }
#regFields { display: flex; flex-direction: column; gap: 6px; }
.f-col { display: flex; flex-direction: column; gap: 6px; }
@media (max-height: 500px) and (min-width: 560px) {
  .auth-card { width: min(640px, 100%); padding: 12px 18px 10px; }
  .auth-card .logo, .auth-card .tagline, #perks, .auth-card .fine:not(.nb-note) { display: none !important; }
  .auth-card h1 { margin: 0 0 4px; font-size: 22px; }
  #regFields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .nb-note { grid-column: 1 / -1; }
  #authForm input { padding: 9px 12px; }
  .gender button { padding: 8px; }
}
.key-input { text-transform: uppercase; letter-spacing: 6px; font-weight: 800; text-align: center; font-size: 20px !important; }
.okmsg { color: #1f8a4c; font-weight: 700; font-size: 13px; text-align: center; }
.okmsg:empty { display: none; }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: underline; padding: 4px; margin-top: 2px; }
.fine { font-size: 11px; color: var(--ink2); margin: 4px 0 0; text-align: center; }
.ig { display: inline-block; margin-top: 10px; font-weight: 700; color: #c13584; text-decoration: none; }

/* ------------------------------------------------ hud */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#hud .area, #hud .feed, #hud .toasts, #hud .keys-hint, #hud .announce { pointer-events: none; }
.chip { background: var(--glass); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.12) !important; border-radius: 12px; padding: 6px 10px; backdrop-filter: blur(6px); font-size: 13px; font-weight: 600; }
.hud-tl { position: absolute; top: 8px; left: calc(8px + var(--safe-l)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.profile { display: flex; align-items: center; gap: 8px; text-align: left; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: rgba(255,255,255,.18); }
.pinfo { display: flex; flex-direction: column; gap: 3px; }
.name { font-weight: 800; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.bar { display: inline-block; width: 70px; height: 7px; border-radius: 9px; background: rgba(255,255,255,.22); overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; width: 0; background: #7CFC9A; border-radius: 9px; transition: width .4s; }
.bar.e i { background: linear-gradient(90deg, #ffd23f, #ffb81f); }
.stats { display: flex; gap: 12px; align-items: center; }
.energy { display: flex; align-items: center; gap: 4px; }
.inv { display: flex; gap: 10px; font-size: 13px; }
.inv:empty { display: none; }
.hud-tr { position: absolute; top: 8px; right: calc(8px + var(--safe-r)); display: flex; gap: 6px; align-items: center; }
.hbtn { position: relative; background: var(--glass); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); border-radius: 12px; height: 40px; min-width: 40px; padding: 0 10px; display: flex; align-items: center; gap: 6px; font-size: 18px; backdrop-filter: blur(6px); }
.hbtn span { font-size: 13px; font-weight: 700; }
.hbtn:active { transform: scale(.94); }
.badge { position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; border-radius: 99px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }
.clock { font-variant-numeric: tabular-nums; }
.hbtn.home { background: rgba(255,184,31,.95); color: var(--accent-ink); }
.hbtn.bikebtn { background: rgba(226,65,59,.92); color: #fff; }
.minimap { position: absolute; top: 56px; right: calc(8px + var(--safe-r)); width: 150px; height: 150px; border-radius: 16px; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 6px 20px rgba(0,0,0,.25); background: #2b8fd8; cursor: pointer; }
.area { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-family: var(--head); font-size: 22px; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.5); opacity: 0; transition: opacity .6s; white-space: nowrap; }
.area.show { opacity: 1; }
.waypoint { position: absolute; top: 214px; right: calc(8px + var(--safe-r)); background: rgba(255,184,31,.95); color: var(--accent-ink); font-weight: 800; font-size: 13px; padding: 6px 6px 6px 12px; border-radius: 12px; display: flex; gap: 8px; align-items: center; }
.waypoint button { background: rgba(0,0,0,.12); width: 24px; height: 24px; border-radius: 8px; font-size: 12px; }
.prompt { position: absolute; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: rgba(20,28,40,.82); color: #fff; padding: 10px 18px; border: 2px solid rgba(255,207,63,.9); border-radius: 14px; font-weight: 800; font-size: 15px; cursor: pointer; pointer-events: auto; box-shadow: 0 6px 18px rgba(0,0,0,.25); animation: promptIn .2s ease-out; }
.prompt:hover { background: rgba(20,28,40,.95); }
@keyframes promptIn { from { transform: translateX(-50%) scale(.9); opacity: 0; } }
button.chip { border: 0; cursor: pointer; font: inherit; color: #fff; text-align: left; }
button.chip.inv:empty { display: none; }
.prompt kbd { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 1px 7px; margin-right: 6px; font-family: inherit; }
.toasts { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(92vw, 460px); }
.toast { background: var(--glass2); color: #fff; padding: 9px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; text-align: center; animation: tin .3s ease-out; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.quest, .toast.level { background: linear-gradient(135deg, #ffb81f, #ff8a3d); color: #3b2000; }
.toast.place { background: linear-gradient(135deg, #2fb35a, #1f9ad6); }
.toast.friend { background: linear-gradient(135deg, #ff6fb5, #8338ec); }
.toast.coins { background: linear-gradient(135deg, #f2c230, #e0a526); color: #3b2a00; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .4s; }
@keyframes tin { from { opacity: 0; transform: translateY(-10px) scale(.95); } }
.announce { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); width: min(90vw, 560px); background: linear-gradient(135deg, #8338ec, #ff6fb5); color: #fff; font-family: var(--head); font-size: 22px; text-align: center; padding: 16px 20px; border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.3); animation: tin .4s; }
.feed { position: absolute; left: calc(8px + var(--safe-l)); bottom: calc(170px + var(--safe-b)); width: min(46vw, 340px); display: flex; flex-direction: column; gap: 4px; }
.feed div { background: rgba(20,26,40,.5); color: #fff; padding: 4px 8px; border-radius: 8px; font-size: 12px; transition: opacity 1s; overflow-wrap: anywhere; }
.feed b { color: #ffd166; }
.feed .all b { color: #9be7ff; }
.feed .dm b { color: #ff9fcf; }
.keys-hint { position: absolute; bottom: calc(6px + var(--safe-b)); left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.85); font-size: 11px; text-shadow: 0 1px 3px rgba(0,0,0,.6); white-space: nowrap; }
.conn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--glass2); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; }

/* touch controls: only for touch devices */
.pad, .actions { display: none; }
body.touch .pad, body.touch .actions { display: flex; }
body.touch .keys-hint { display: none; }
body.touch .prompt kbd { display: none; }
body.touch .prompt { bottom: calc(14px + var(--safe-b)); font-size: 16px; padding: 12px 20px; }
.pad { position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(16px + var(--safe-b)); width: 150px; height: 150px; border-radius: 50%; background: rgba(20,26,40,.35); border: 2px solid rgba(255,255,255,.25); touch-action: none; }
.pad .arrow { position: absolute; color: rgba(255,255,255,.8); font-size: 20px; width: 44px; height: 44px; display: grid; place-items: center; }
.pad .up { top: 2px; left: 53px; } .pad .down { bottom: 2px; left: 53px; } .pad .left { left: 2px; top: 53px; } .pad .right { right: 2px; top: 53px; }
.pad .arrow.on { color: var(--accent); }
.knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.6); transition: transform .05s; }
.actions { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 220px; height: 160px; }
.act { position: absolute; border-radius: 50%; background: rgba(20,26,40,.55); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; border: 2px solid rgba(255,255,255,.3); touch-action: none; line-height: 1; }
.act small { font-size: 10px; font-weight: 700; margin-top: 2px; }
.act:active, .act.on { transform: scale(.92); background: rgba(255,184,31,.85); color: var(--accent-ink); }
.act.main { right: 0; bottom: 6px; width: 86px; height: 86px; font-size: 30px; background: rgba(255,184,31,.85); color: var(--accent-ink); }
.act.main.idle { background: rgba(20,26,40,.45); color: rgba(255,255,255,.6); }
.act.jump { right: 96px; bottom: 0; width: 62px; height: 62px; }
.act.bike { right: 82px; bottom: 82px; width: 62px; height: 62px; }
.act.run { right: 158px; bottom: 30px; width: 56px; height: 56px; font-size: 20px; }
.act.run.on { background: rgba(255,120,60,.9); color: #fff; }
.act.bike.on { background: rgba(47,179,90,.9); color: #fff; }

/* chat */
.chat { position: absolute; top: 56px; z-index: 31; right: calc(8px + var(--safe-r)); bottom: 10px; width: min(360px, 48vw); background: rgba(255,255,255,.97); border-radius: 16px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.3); overflow: hidden; z-index: 30; }
.chat header { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid #eef1f6; }
.ctabs { display: flex; flex: 1; background: #eef1f6; border-radius: 10px; padding: 3px; }
.ctabs button { flex: 1; padding: 6px 4px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--ink2); }
.ctabs button.active { background: #fff; color: var(--ink); }
.x { width: 32px; height: 32px; border-radius: 10px; background: #eef1f6; font-weight: 800; flex: none; }
.dm-pick { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; border-bottom: 1px solid #eef1f6; touch-action: pan-x; }
.dm-pick button { flex: none; padding: 5px 10px; border-radius: 99px; background: #eef1f6; font-size: 12px; font-weight: 700; }
.dm-pick button.active { background: var(--accent); }
.msgs { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; touch-action: pan-y; user-select: text; }
.msg { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.msg b { color: var(--blue); }
.msg.me b { color: #c27b00; }
.msg .empty { color: var(--ink2); }
.empty { color: var(--ink2); font-size: 13px; text-align: center; padding: 14px 6px; }
#chatForm { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #eef1f6; }
#chatForm input { flex: 1; min-width: 0; padding: 9px 10px; border: 2px solid #dfe4ec; border-radius: 10px; outline: none; font-size: 16px; }
.chat .fine { padding: 0 8px 6px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10,16,30,.45); display: grid; place-items: center; z-index: 40; padding: 10px; }
.sheet { background: #fff; width: min(620px, 100%); max-height: calc(100dvh - 20px); border-radius: 20px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: pop .22s ease-out; overflow: hidden; }
.sheet.wide { width: min(920px, 100%); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.sheet h2 { font-family: var(--head); margin: 0; font-size: 22px; }
.mbody { padding: 4px 14px 14px; overflow-y: auto; touch-action: pan-y; }
.mbody h3 { font-family: var(--head); margin: 14px 0 6px; font-size: 17px; }
.mbody p { margin: 6px 0; line-height: 1.45; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; background: #f5f7fb; padding: 10px; border-radius: 12px; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 800; }
.item .d { font-size: 12px; color: var(--ink2); }
.item.done { background: #e9f8ee; }
.item.done .t::after { content: ' ✓'; color: var(--green); }
.prog { height: 6px; background: #e3e7ef; border-radius: 9px; overflow: hidden; margin-top: 5px; }
.prog i { display: block; height: 100%; background: var(--green); }
.reward { font-size: 12px; font-weight: 800; color: #a06a00; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c3c9d4; display: inline-block; }
.dot.on { background: var(--green); }
.role-card { border-radius: 16px; padding: 14px; color: #fff; display: flex; gap: 12px; align-items: center; }
.role-card .big { font-size: 42px; }
.role-card.police { background: linear-gradient(135deg, #2f6fd6, #1d3f8a); }
.role-card.thief { background: linear-gradient(135deg, #7b3fb8, #2a1747); }
.role-card.citizen { background: linear-gradient(135deg, #e08a2b, #8a4a12); }
.role-card .t { font-family: var(--head); font-size: 20px; }
.role-card .d { font-size: 13px; opacity: .9; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; background: #f5f7fb; border-radius: 12px; padding: 8px; border: 2px solid transparent; text-align: left; }
.swatch.eq { border-color: var(--green); }
.swatch i { width: 26px; height: 26px; border-radius: 8px; flex: none; }
.swatch .p { font-size: 12px; color: var(--ink2); font-weight: 700; }
.mapwrap { position: relative; width: 100%; }
.mapwrap canvas { width: 100%; display: block; border-radius: 12px; background: #2b8fd8; cursor: grab; touch-action: none; }
.mapzoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.mapzoom button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.95); font-size: 20px; font-weight: 800; color: #1d2b24; box-shadow: 0 2px 8px rgba(0,0,0,.2); cursor: pointer; }
.upd-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 200; background: #1f8a4c; color: #fff; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.3); cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--ink2); margin-top: 8px; }
.welcome { text-align: center; }
.welcome .role-reveal { margin: 10px auto; max-width: 380px; animation: reveal .8s ease-out; }
@keyframes reveal { 0% { transform: rotateY(90deg) scale(.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
.kbd-table { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kbd-table kbd { background: #eef1f6; border-radius: 6px; padding: 1px 7px; font-family: inherit; font-weight: 700; }
input.inline { padding: 9px 10px; border: 2px solid #dfe4ec; border-radius: 10px; outline: none; font-size: 16px; flex: 1; min-width: 120px; }

#fade { position: fixed; inset: 0; background: #0b1024; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 60; display: grid; place-items: center; }
#fade.on { opacity: 1; pointer-events: auto; }
#fadeText { color: #fff; font-family: var(--head); font-size: 40px; animation: bob 2s infinite; }

#rotate { position: fixed; inset: 0; z-index: 100; background: linear-gradient(160deg, #2fb35a, #1f9ad6); color: #fff; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; font-family: var(--head); }
#rotate .phone { font-size: 70px; animation: turn 2s ease-in-out infinite; }
#rotate p { font-size: 24px; margin: 18px 0 6px; }
#rotate small { font-family: system-ui; opacity: .9; }
@keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }


@media (max-width: 980px) { .hbtn span { display: none; } }
/* compact phones in landscape */
@media (max-height: 500px) {
  .hbtn span { display: none; }
  .hbtn { height: 36px; min-width: 36px; padding: 0 8px; font-size: 17px; }
  .chip { padding: 4px 8px; font-size: 12px; }
  .avatar { width: 26px; height: 26px; font-size: 15px; }
  .area { font-size: 18px; top: 46px; }
  .toasts { top: 64px; }
  .toast { font-size: 12px; padding: 7px 12px; }
  .waypoint { top: 158px; font-size: 12px; }
  .minimap { top: 48px; width: 104px; height: 104px; border-radius: 12px; }
  .pad { width: 128px; height: 128px; }
  .pad .up, .pad .down { left: 42px; } .pad .left, .pad .right { top: 42px; }
  .actions { transform: scale(.9); transform-origin: bottom right; }
  .feed { bottom: calc(150px + var(--safe-b)); font-size: 11px; }
  .chat { top: 48px; }
  .sheet { border-radius: 16px; }
  .sheet h2 { font-size: 19px; }
  .auth-card { padding: 14px 18px 12px; }
  .logo { font-size: 32px; } h1 { font-size: 26px; }
  .tagline { display: none; }
  #auth { place-items: start center; }
}
@media (max-width: 640px) and (orientation: portrait) {
  .feed { width: 60vw; }
}

.nblist { max-height: min(52vh, 420px); overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.nbcount { font-size: 12px; color: #5a6478; font-weight: 700; margin: 0 2px 2px; }
.nbcount:empty { display: none; }
.loadmore { width: 100%; margin-top: 4px; }

#keyReveal { text-align: center; }
.kr-title { font-weight: 800; font-size: 18px; margin: 4px 0 8px; }
.kr-key { font-size: 40px; font-weight: 900; letter-spacing: 10px; background: #fff8e1; border: 3px dashed #f2c230; border-radius: 16px; padding: 12px 8px 12px 18px; margin-bottom: 10px; user-select: all; color: #3b2a00; }
.kr-note { font-size: 13px; color: #5a3d00; background: #fff3e0; border-radius: 12px; padding: 10px; margin: 10px 0; text-align: left; }
.kr-check { display: flex; gap: 8px; align-items: center; justify-content: center; font-weight: 700; margin: 6px 0 10px; }
.kr-check input { width: 20px; height: 20px; }
#krGo:disabled { opacity: .5; }

/* Phones held upright: the whole game is turned sideways, so it always plays in landscape */
body.rot { position: fixed; top: 0; transform: rotate(90deg); transform-origin: top left; overflow: hidden; }
body.rot .hbtn span { display: none; }
body.rot .hbtn { height: 36px; min-width: 36px; padding: 0 8px; font-size: 17px; }
body.rot .chip { padding: 4px 8px; font-size: 12px; }
body.rot .avatar { width: 26px; height: 26px; font-size: 15px; }
body.rot .area { font-size: 18px; top: 46px; }
body.rot .toasts { top: 64px; }
body.rot .toast { font-size: 12px; padding: 7px 12px; }
body.rot .waypoint { top: 158px; font-size: 12px; }
body.rot .minimap { top: 48px; width: 104px; height: 104px; border-radius: 12px; }
body.rot .pad { width: 128px; height: 128px; }
body.rot .pad .up, body.rot .pad .down { left: 42px; }
body.rot .pad .left, body.rot .pad .right { top: 42px; }
body.rot .actions { transform: scale(.9); transform-origin: bottom right; }
body.rot .feed { bottom: calc(150px + var(--safe-b)); font-size: 11px; }
body.rot .chat { top: 48px; }
body.rot .sheet { border-radius: 16px; }
body.rot .sheet h2 { font-size: 19px; }
body.rot .auth-card { padding: 14px 18px 12px; }
body.rot .logo { font-size: 32px; }
body.rot h1 { font-size: 26px; }
body.rot .tagline { display: none; }
body.rot #auth { place-items: start center; }
body.rot .auth-card { width: min(640px, 100%); padding: 12px 18px 10px; }
body.rot .auth-card .logo, body.rot .auth-card .tagline, body.rot #perks, body.rot .auth-card .fine:not(.nb-note) { display: none !important; }
body.rot .auth-card h1 { margin: 0 0 4px; font-size: 22px; }
body.rot #regFields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
body.rot .nb-note { grid-column: 1 / -1; }
body.rot #authForm input { padding: 9px 12px; }
body.rot .gender button { padding: 8px; }

#newsPop { position: fixed; inset: 0; z-index: 90; background: rgba(10,15,25,.45); display: grid; place-items: center; padding: 16px; animation: tin .25s ease-out; }
#newsPop[hidden] { display: none; }
.news-card { position: relative; width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 22px 20px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; border-top: 6px solid #a855f7; }
.news-card .x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: #eef1f6; font-size: 16px; cursor: pointer; }
.news-tag { display: inline-block; background: #f3e8ff; color: #6b21a8; font-weight: 800; font-size: 12px; border-radius: 99px; padding: 4px 10px; }
.news-card h2 { margin: 10px 0 6px; font-size: 20px; }
.news-card p { margin: 0 0 14px; color: #334; font-size: 15px; white-space: pre-wrap; }
.notes .item .d { white-space: pre-wrap; }
.notes .item.unread { border-left: 4px solid #a855f7; }

.pad.locked { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,207,63,.35); }
.pad.locked .knob { background: rgba(255,207,63,.75); }
.pad.locked::after { content: '🔒'; position: absolute; right: -6px; top: -6px; font-size: 20px; }

.lockbtn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(74px + var(--safe-b)); background: rgba(217,130,43,.95); color: #fff; border: 0; border-radius: 12px; padding: 8px 14px; font-weight: 800; font-size: 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.lockbtn.locked { background: rgba(47,179,90,.92); }
body.touch .lockbtn { bottom: calc(78px + var(--safe-b)); font-size: 15px; padding: 10px 16px; }
