/* Drift Crew: chunky cartoon UI (Fredoka) over a full-screen three.js canvas. Phones in landscape are the main layout. */
:root { --ink: #12324a; --cream: #fff8e6; --sea: #1fa3c8; --deep: #0b4f7a; --gold: #ffc83a; --gold-d: #c98a0a; --coral: #ff6b5e; --leaf: #4cc16b;
    --glass: rgba(10, 45, 70, .62); --line: #0a2d46;
    --sat: env(safe-area-inset-top); --sar: env(safe-area-inset-right); --sab: env(safe-area-inset-bottom); --sal: env(safe-area-inset-left); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--deep); }
body { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 500; color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.screen { position: fixed; inset: 0; }
h1, h2, h3, h4 { font-weight: 700; margin: 0 0 6px; }
.hint { color: #3d6684; font-size: 15px; margin: 6px 0; }
.msg { color: #c22; font-weight: 600; min-height: 1.3em; margin: 6px 0; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.center { justify-content: center; text-align: center; }
.link { background: none; border: 0; font: inherit; color: var(--deep); text-decoration: underline; cursor: pointer; padding: 6px; }

/* chunky buttons */
.btn { font: 700 18px 'Fredoka', sans-serif; color: var(--ink); background: #fff; border: 4px solid var(--line); border-radius: 18px; padding: 10px 20px; min-height: 48px; cursor: pointer;
    box-shadow: 0 5px 0 var(--line); transition: transform .06s, box-shadow .06s; touch-action: manipulation; }
.btn:active, .btn.down { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.btn.big { font-size: 22px; padding: 14px 26px; min-height: 58px; }
.btn.gold { background: linear-gradient(#ffe27a, var(--gold)); }
.btn.danger { background: #ffb3ab; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.btn:disabled { opacity: .5; }
input, select { font: 600 18px 'Fredoka', sans-serif; color: var(--ink); border: 4px solid var(--line); border-radius: 14px; padding: 8px 12px; background: #fff; min-height: 48px; -webkit-user-select: text; user-select: text; }
input[type=range] { padding: 0; accent-color: var(--sea); }
input[type=checkbox] { min-height: 0; width: 26px; height: 26px; accent-color: var(--sea); }

/* ---------- title: animated sea ---------- */
#title { overflow: hidden; background: linear-gradient(#7fd8f5 0%, #c9f1ff 46%, #1fa3c8 46%, #0b4f7a 100%); display: grid; place-items: center; }
.sun { position: absolute; top: 9%; right: 14%; width: 14vmin; height: 14vmin; border-radius: 50%; background: radial-gradient(#fff6b0, #ffd23f); box-shadow: 0 0 60px 20px rgba(255, 220, 90, .55); }
.sea { position: absolute; left: 0; right: 0; top: 46%; bottom: 0; overflow: hidden; }
.wave { position: absolute; left: -10%; width: 120%; height: 40%; border-radius: 50% 50% 0 0 / 100% 100% 0 0; opacity: .55; animation: sway 6s ease-in-out infinite; }
.w1 { top: -6%; background: #4fd0ee; } .w2 { top: 18%; background: #1fa3c8; animation-duration: 8s; animation-direction: reverse; } .w3 { top: 44%; background: #0e6aa0; animation-duration: 10s; }
@keyframes sway { 50% { transform: translateX(5%) translateY(6px); } }
.scene { position: absolute; left: 0; right: 0; top: 36%; height: 30%; pointer-events: none; }
.raft-emoji { position: absolute; left: 14%; top: 10%; font-size: min(15vmin, 110px); animation: bob 3.4s ease-in-out infinite; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, .18)); }
.fin { position: absolute; right: 18%; top: 28%; font-size: min(10vmin, 70px); animation: fin 9s linear infinite; }
@keyframes fin { 0% { transform: translateX(80px) scaleX(-1); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateX(-30vw) scaleX(-1); opacity: 0; } }
.gull { position: absolute; font-size: 28px; animation: glide 16s linear infinite; opacity: .85; }
.g1 { top: -50%; left: -10%; } .g2 { top: -90%; left: -30%; animation-delay: -7s; font-size: 20px; }
@keyframes glide { to { transform: translateX(130vw) translateY(-20px); } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
.title-box { position: relative; text-align: center; padding: 12px; z-index: 1; margin-top: -4vh; }
.logo { font-size: min(18vmin, 120px); line-height: .9; color: #fff; text-shadow: 0 6px 0 var(--deep), 0 10px 0 rgba(0, 0, 0, .25), -4px 0 0 var(--deep), 4px 0 0 var(--deep); letter-spacing: 1px; animation: bob 4s ease-in-out infinite; }
.logo span { display: inline-block; } .logo .b { color: var(--gold); margin-left: .18em; transform: rotate(-3deg); }
.tag { color: #fff; font-weight: 600; font-size: 20px; text-shadow: 0 3px 0 rgba(0, 0, 0, .5); margin: 8px 0 14px; }
.title-box .col { width: min(340px, 84vw); margin: 0 auto; }
@media (max-height: 460px) { .title-box .col { flex-direction: row; flex-wrap: wrap; width: 90vw; justify-content: center; } .tag { margin: 4px 0 8px; font-size: 16px; } .logo { font-size: 17vmin; } }

/* ---------- menus ---------- */
.menu { overflow: auto; touch-action: pan-y; background: linear-gradient(#5fc7e8, #1fa3c8 40%, #0b4f7a); }
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: max(8px, var(--sat)) max(14px, var(--sar)) 8px max(14px, var(--sal)); background: rgba(10, 45, 70, .85); color: #fff; }
.bar h2 { flex: 1; margin: 0; font-size: 22px; text-align: center; }
.room { font-size: 16px; letter-spacing: 3px; background: #fff3; padding: 2px 10px; border-radius: 10px; margin-left: 6px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 18px max(16px, var(--sar)) 30px max(16px, var(--sal)); max-width: 980px; margin: 0 auto; }
.cards .msg { grid-column: 1 / -1; color: #ffe0dc; }
@media (max-width: 700px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--cream); border: 4px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: 0 8px 0 rgba(0, 0, 0, .28); }
.bigcode { font-size: 54px; font-weight: 700; letter-spacing: 10px; text-align: center; color: var(--deep); background: #fff; border: 4px dashed var(--sea); border-radius: 16px; margin: 8px 0 12px; padding: 4px 0 4px 10px; -webkit-user-select: text; user-select: text; }
.codeboxes { display: flex; gap: 8px; margin: 8px 0 14px; }
.codeboxes input { width: 100%; min-width: 0; text-align: center; font-size: 28px; font-weight: 700; text-transform: uppercase; padding: 4px 0; min-height: 60px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 18px max(16px, var(--sar)) 24px max(16px, var(--sal)); max-width: 980px; margin: 0 auto; }
.slot { font: inherit; background: var(--cream); border: 4px solid var(--line); border-radius: 22px; padding: 10px; text-align: center; cursor: pointer; box-shadow: 0 6px 0 rgba(0, 0, 0, .3); color: var(--ink); touch-action: manipulation; }
.slot:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.slot b { display: block; font-size: 20px; } .slot small { color: #4d7692; font-size: 13px; }
.slot.add { background: #fff6c8; display: grid; place-items: center; min-height: 170px; font-size: 20px; font-weight: 700; border-style: dashed; }
.avatar { width: 96px; height: 110px; margin: 0 auto 4px; border-radius: 16px; background: radial-gradient(circle at 50% 35%, #fff, #bfeaf7); display: grid; place-items: center; overflow: hidden; font-size: 54px; }
.avatar img, .avatar canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.avatar.big { width: 140px; height: 170px; margin: 0; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(5, 25, 40, .66); display: grid; place-items: center; padding: 12px; overflow: auto; touch-action: pan-y; }
.modal .card { width: min(380px, 100%); text-align: center; }
.modal .card.wide { width: min(640px, 100%); text-align: left; }
.modal .card h3 { text-align: center; }
.modal input { width: 100%; }
.newp-grid { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
@media (max-width: 480px) { .newp-grid { grid-template-columns: 1fr; } .avatar.big { margin: 0 auto; width: 110px; height: 130px; } }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line); cursor: pointer; padding: 0; }
.sw[aria-pressed=true] { box-shadow: 0 0 0 4px var(--gold); transform: scale(1.1); }
.pickrow { display: flex; align-items: center; gap: 8px; } .pickrow span { width: 44px; font-weight: 700; }
.pick { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pick button { font: inherit; font-size: 24px; min-width: 46px; height: 46px; border: 3px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; padding: 0 6px; }
.pick button[aria-pressed=true] { background: #fff2b8; box-shadow: 0 0 0 3px var(--gold); }

.toast { position: fixed; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%); z-index: 40; background: #fff; border: 4px solid var(--line); border-radius: 16px; padding: 10px 18px; font-weight: 700; max-width: 90vw; }

/* ---------- game: controls ---------- */
#game { touch-action: none; }
#touch { position: absolute; inset: 0; z-index: 3; touch-action: none; }
#stick { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, .16); border: 4px solid rgba(255, 255, 255, .5); opacity: 0; pointer-events: none; transition: opacity .12s; }
#stick.on { opacity: 1; }
#stick i { position: absolute; left: 36px; top: 36px; width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, .8); border: 4px solid var(--line); }
.btns { position: absolute; display: flex; gap: 10px; pointer-events: none; }
.btns > * { pointer-events: auto; }
.btns.right { right: max(14px, var(--sar)); bottom: max(14px, var(--sab)); width: 270px; flex-wrap: wrap-reverse; justify-content: flex-end; align-content: flex-end; row-gap: 32px; }
.lefty .btns.right { right: auto; left: max(14px, var(--sal)); }
.btns.left-top { left: max(12px, var(--sal)); top: 112px; flex-direction: column; gap: 14px; }
.lefty .btns.left-top { left: auto; right: max(12px, var(--sar)); }
.act { position: relative; font: 700 26px 'Fredoka', sans-serif; width: 66px; height: 66px; border-radius: 50%; border: 4px solid var(--line); background: rgba(255, 255, 255, .88); color: var(--ink); box-shadow: 0 5px 0 var(--line); padding: 0; display: grid; place-items: center; line-height: 1; cursor: pointer; touch-action: none; }
.act small { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 11px; font-weight: 700; text-align: center; opacity: .75; }
.act { align-content: center; padding-bottom: 8px; }
.act.sm { width: 54px; height: 54px; font-size: 20px; padding-bottom: 13px; }
.act.sm small { font-size: 10px; bottom: 3px; }
.act.main { width: 84px; height: 84px; font-size: 32px; background: linear-gradient(#ffe27a, var(--gold)); }
.act.main .ic { display: block; margin-top: -6px; }
.act.main small { bottom: calc(100% + 6px); left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: 150px; background: #fff; border: 3px solid var(--line); border-radius: 12px; padding: 1px 10px; font-size: 14px; opacity: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act.down, .act:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.act .ring { position: absolute; inset: -8px; border-radius: 50%; border: 6px solid transparent; pointer-events: none; }
.act.holding .ring { border-top-color: #fff; border-right-color: #fff; animation: spin 1s linear infinite; }
.act.dim { opacity: .45; }
.act.tog[aria-pressed=true] { background: var(--gold); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-height: 460px) { .newp-grid { grid-template-columns: 110px 1fr; } .avatar.big { width: 100px; height: 120px; } .modal .card { padding: 10px; } .pick button { min-width: 40px; height: 40px; font-size: 20px; } .sw { width: 34px; height: 34px; } }
@media (max-height: 420px) { .act { width: 58px; height: 58px; font-size: 22px; } .act.main { width: 74px; height: 74px; } .btns.right { width: 240px; } .btns.left-top { top: 104px; gap: 8px; } }

/* ---------- game: HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#hud button, #hud .hotbar .slot { pointer-events: auto; }
.bars { position: absolute; left: max(10px, var(--sal)); top: max(10px, var(--sat)); display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; gap: 4px; }
.bar-row i { font-style: normal; font-size: 20px; width: 26px; text-align: center; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .35)); }
.bar-row b { display: block; width: 118px; height: 15px; background: rgba(0, 0, 0, .45); border: 3px solid var(--line); border-radius: 10px; overflow: hidden; }
.bar-row u { display: block; height: 100%; width: 100%; text-decoration: none; border-radius: 6px; transition: width .25s; }
.hp u { background: linear-gradient(#ff8a80, #ff3d3d); } .food u { background: linear-gradient(#ffcd6b, #f19a1e); } .water u { background: linear-gradient(#7fe0ff, #1c9bd8); }
.bar-row.low { animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.breath { position: absolute; left: max(176px, calc(var(--sal) + 176px)); top: 8px; width: 52px; height: 52px; }
.breath svg { width: 100%; height: 100%; transform: rotate(-90deg); } .breath circle { fill: rgba(0, 40, 70, .4); stroke: rgba(255, 255, 255, .25); stroke-width: 5; }
.breath #breath-arc { fill: none; stroke: #8be9ff; stroke-linecap: round; stroke-dasharray: 100.5; transition: stroke-dashoffset .2s; }
.breath i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 22px; }
.topmid { position: absolute; left: 50%; top: max(8px, var(--sat)); transform: translateX(-50%); display: flex; gap: 8px; align-items: center; }
.compass, .clock { background: var(--glass); color: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 4px 12px; font-weight: 700; font-size: 15px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
#compass-needle { font-style: normal; display: inline-block; transition: transform .3s; color: var(--gold); }
.topright { position: absolute; right: max(10px, var(--sar)); top: max(8px, var(--sat)); display: flex; gap: 8px; }
.ib { font: inherit; font-size: 22px; width: 48px; height: 48px; border-radius: 14px; border: 3px solid var(--line); background: var(--glass); color: #fff; cursor: pointer; padding: 0; touch-action: manipulation; }
.ib:active { transform: translateY(2px); }
.chapter { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(8px, var(--sat)) + 44px); width: max-content; max-width: min(330px, 46vw); text-align: left; font: inherit; background: var(--glass); color: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 10px; cursor: pointer; display: none; }
.chapter b { display: block; font-size: 14px; color: var(--gold); } .chapter span { display: block; font-size: 13px; line-height: 1.25; } .chapter em { display: none; font-size: 12px; font-style: normal; opacity: .85; margin-top: 4px; }
.chapter.open em { display: block; } .chapter.show { display: block; }
.banner { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); font-size: 34px; font-weight: 700; color: #fff; text-shadow: 0 4px 0 var(--deep), 0 0 18px rgba(0, 0, 0, .4); animation: banner 3s forwards; white-space: nowrap; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 20px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.hotbar { position: absolute; left: 50%; bottom: max(8px, var(--sab)); transform: translateX(-50%); display: flex; gap: 5px; }
.hotbar .slot, .grid .slot { position: relative; width: 52px; height: 52px; border-radius: 12px; border: 3px solid var(--line); background: rgba(255, 255, 255, .78); display: grid; place-items: center; font-size: 28px; padding: 0; cursor: pointer; color: var(--ink); touch-action: manipulation; box-shadow: none; }
.slot[aria-pressed=true], .slot.sel { background: #fff2b8; box-shadow: 0 0 0 3px var(--gold); transform: translateY(-4px); }
.slot .n { position: absolute; right: 3px; bottom: 0; font-size: 13px; font-weight: 700; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.slot .k { position: absolute; left: 3px; top: 0; font-size: 10px; opacity: .55; }
.slot .dur { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 4px; background: #0003; border-radius: 3px; overflow: hidden; } .slot .dur i { display: block; height: 100%; background: var(--leaf); }
@media (max-height: 420px) { .hotbar .slot { width: 46px; height: 46px; font-size: 24px; } }
.toasts { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.tst { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 5px 14px; font-weight: 700; font-size: 16px; animation: tst 3.4s forwards; box-shadow: 0 3px 0 var(--line); white-space: nowrap; }
.tst.good { background: #d8ffd8; } .tst.bad { background: #ffd8d4; } .tst.say { background: #fff8c9; }
@keyframes tst { 0% { opacity: 0; transform: translateY(-10px) scale(.8); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.held-tip { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); background: var(--glass); color: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 12px; font-size: 14px; max-width: 300px; text-align: center; }
.reconnect { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); background: #ffe27a; border: 3px solid var(--line); border-radius: 12px; padding: 4px 14px; font-weight: 700; animation: pulse .7s infinite alternate; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 0 0 2px rgba(0, 0, 0, .4); }
.aim { position: absolute; left: 50%; top: 50%; width: 90px; height: 90px; margin: -45px; border-radius: 50%; border: 4px dashed #fff; }
.aim i { position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 255, 255, .25); transform-origin: center; transform: scale(0); }

/* build placement bar */
.placebar { position: absolute; z-index: 6; left: 50%; bottom: calc(66px + var(--sab)); transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: var(--glass); border: 3px solid var(--line); border-radius: 26px; padding: 8px 12px; }
.pl-name { color: #fff; font-weight: 700; min-width: 90px; text-align: center; font-size: 15px; }
.act.ok { background: linear-gradient(#9af0a8, var(--leaf)); }
.placebar .act { width: 52px; height: 52px; } .placebar .act.main { width: 66px; height: 66px; padding-bottom: 0; }

/* ---------- panels ---------- */
.panel { position: absolute; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, calc(100vw - 20px - var(--sal) - var(--sar))); max-height: calc(100% - 20px - var(--sat) - var(--sab)); overflow: auto;
    background: var(--cream); border: 4px solid var(--line); border-radius: 22px; padding: 10px 14px 14px; box-shadow: 0 8px 0 rgba(0, 0, 0, .3); touch-action: pan-y; animation: pop .18s; }
.panel.narrow { width: min(440px, calc(100vw - 20px)); }
@keyframes pop { from { transform: translate(-50%, -46%) scale(.94); opacity: 0; } }
.panel header { display: flex; align-items: center; gap: 10px; position: sticky; top: -10px; background: var(--cream); padding: 6px 0 8px; z-index: 1; }
.panel header h3 { flex: 1; margin: 0; font-size: 22px; }
.panel header input { width: 150px; min-height: 40px; font-size: 16px; }
.x { font: 700 20px 'Fredoka'; width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--line); background: #ffd0cb; cursor: pointer; padding: 0; }
.tog { font: 700 15px 'Fredoka'; border: 3px solid var(--line); border-radius: 12px; background: #fff; padding: 6px 12px; min-height: 40px; cursor: pointer; }
.tog[aria-pressed=true] { background: var(--gold); }
.split { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
@media (max-width: 600px) { .split { grid-template-columns: 1fr; } }
.grid { display: grid; grid-template-columns: repeat(6, 54px); gap: 6px; align-content: start; align-self: start; }
.grid.small { grid-template-columns: repeat(5, 54px); }
.grid .slot { width: 54px; height: 54px; background: #fff; }
.grid .slot.empty { background: #e6f3f8; }
.grid .slot.hot { border-color: var(--gold-d); }
.detail { min-height: 90px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.detail b { font-size: 18px; } .detail p { margin: 4px 0; font-size: 14px; } .detail .row { margin-top: 6px; }
.detail .btn { min-height: 40px; font-size: 15px; padding: 4px 12px; box-shadow: 0 3px 0 var(--line); }
.chest { margin-top: 8px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; touch-action: pan-x; }
.tabs button { font: 700 15px 'Fredoka'; white-space: nowrap; border: 3px solid var(--line); border-radius: 12px; background: #fff; padding: 6px 12px; min-height: 42px; cursor: pointer; }
.tabs button[aria-pressed=true] { background: var(--sea); color: #fff; }
.recipes, .pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.rcp { text-align: left; font: inherit; color: var(--ink); background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 8px 10px; cursor: pointer; display: grid; grid-template-columns: 44px 1fr; gap: 2px 8px; align-items: center; touch-action: manipulation; }
.rcp .ico { font-size: 34px; grid-row: span 2; text-align: center; }
.rcp b { font-size: 16px; line-height: 1.1; } .rcp small { grid-column: 2; font-size: 12.5px; color: #3d6684; line-height: 1.25; }
.rcp .need { grid-column: 1 / -1; font-size: 13px; display: flex; flex-wrap: wrap; gap: 3px 8px; }
.need .ok { color: #168a35; } .need .no { color: #c22; font-weight: 700; }
.rcp.can { background: #e4ffe9; border-color: #1a8a3a; } .rcp.locked { opacity: .5; filter: grayscale(.6); }
.rcp .blurb { grid-column: 1 / -1; font-size: 12px; color: #3d6684; }
.wheel { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin: 8px 0; }
.wheel button { font: 700 14px 'Fredoka'; border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 6px; min-height: 58px; cursor: pointer; } .wheel button span { display: block; font-size: 26px; }
.wheel.chat { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } .wheel.chat button { min-height: 44px; }
.plist .pl { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 10px; margin-bottom: 6px; font-weight: 700; }
.plist .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); } .plist small { margin-left: auto; font-weight: 600; color: #3d6684; }
.setrows { display: grid; gap: 14px; } .setrows label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; } .setrows label.chk { justify-content: flex-start; }
.helptext { font-size: 15.5px; line-height: 1.4; } .helptext h4 { margin: 12px 0 2px; color: var(--deep); } .helptext ul { margin: 0; padding-left: 20px; } .helptext kbd { background: #fff; border: 2px solid var(--line); border-radius: 6px; padding: 0 5px; font: inherit; font-size: 13px; }
.modal .helptext { max-height: 60vh; overflow: auto; touch-action: pan-y; }

.downed { position: absolute; inset: 0; z-index: 9; background: radial-gradient(transparent 30%, rgba(40, 90, 140, .6)); display: grid; place-items: center; pointer-events: none; }
.downed .card { text-align: center; max-width: 340px; background: #fffbe8e6; } .downed .count { font-size: 56px; font-weight: 700; color: var(--coral); }
.popup { position: absolute; inset: 0; z-index: 12; background: rgba(5, 25, 40, .5); display: grid; place-items: center; }
.popup .card { text-align: center; width: min(400px, 90vw); animation: pop2 .4s cubic-bezier(.3, 1.6, .5, 1); } .popup .stars { font-size: 52px; }
@keyframes pop2 { from { transform: scale(.4); opacity: 0; } }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 13; }
.rotate { display: none; position: absolute; inset: 0; z-index: 30; background: var(--deep); color: #fff; text-align: center; place-items: center; font-size: 60px; }
.rotate p { font-size: 20px; margin: 0; }
@media (orientation: portrait) and (max-width: 600px) { #game:not([hidden]) .rotate.on { display: grid; } }

/* portrait phones: two rows of top controls, controls lifted above the hotbar */
@media (orientation: portrait) and (max-width: 600px) {
    .topright { top: max(8px, var(--sat)); right: 6px; gap: 5px; } .ib { width: 44px; height: 44px; font-size: 19px; }
    .bars { top: calc(max(8px, var(--sat)) + 76px); }
    .topmid { left: 8px; transform: none; top: max(8px, var(--sat)); flex-direction: column; align-items: flex-start; gap: 4px; }
    .compass, .clock { padding: 3px 8px; font-size: 13px; } #region { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
    .chapter { left: auto; right: 6px; transform: none; top: calc(max(8px, var(--sat)) + 52px); max-width: 160px; }
    .breath { left: auto; right: 10px; top: calc(max(8px, var(--sat)) + 140px); }
    .btns.left-top { top: calc(max(8px, var(--sat)) + 190px); }
    .btns.right { bottom: calc(72px + var(--sab)); width: 230px; }
    .toasts { top: 34%; }
}

/* small landscape phones (iPhone SE, 667x375): hotbar left of the jump button, top row packed */
@media (orientation: landscape) and (max-width: 720px) {
    .hotbar { left: 76px; transform: none; gap: 4px; } .hotbar .slot { width: 44px; height: 44px; font-size: 22px; }
    .topright { gap: 5px; } .ib { width: 44px; height: 44px; font-size: 19px; }
    .topmid { left: 168px; transform: none; gap: 6px; } .compass, .clock { padding: 3px 8px; font-size: 13px; }
    .chapter { left: 168px; transform: none; max-width: 240px; }
    .breath { left: auto; right: 10px; top: 60px; }
}

.helm { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; }
.helm .btn { width: 84px; }
.dial { position: relative; width: 120px; height: 120px; border-radius: 50%; background: #fff; border: 4px solid var(--line); display: grid; place-items: center; }
.dial i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 46px; color: var(--coral); transition: transform .3s; }
.dial b { position: absolute; bottom: 14px; font-size: 18px; }

@media (max-height: 460px) { .downed .card { padding: 8px 14px; } .downed .count { font-size: 40px; line-height: 1.1; } .downed .hint { display: none; } .downed h2 { font-size: 22px; } }
