/* CLOSED CASKET 3D prototype. Same paper/tape/stamp look as the 2D game. No inline styles anywhere
 * (CSP style-src 'self'). Fonts self-hosted (SIL OFL 1.1, see /fonts). Code: 0BSD. */
@font-face { font-family: "IM Fell English SC"; src: url("../fonts/IMFeENsc28P.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("../fonts/CourierPrime-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("../fonts/CourierPrime-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bungee"; src: url("../fonts/Bungee-Regular.woff2") format("woff2"); font-display: swap; }
:root { --night: #0d1424; --deep: #080c17; --sodium: #ffb347; --teal: #3fd0c9; --pink: #ff6fae; --bone: #efe6d2; --paper2: #e6dcc4; --ink: #1b1b1f; --muted: #6b6560; --wine: #8c2f4b; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--deep); color: var(--bone); overflow: hidden; font-family: "Courier Prime", "Courier New", monospace; -webkit-tap-highlight-color: transparent; }
body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.title canvas#c { filter: blur(2px) brightness(.7); }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
[hidden] { display: none !important; }
.screen { position: absolute; inset: 0; display: none; overflow: auto; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen.on { display: flex; }
.screen > .card { margin: auto; }
#scr-title { background: radial-gradient(ellipse at 50% 120%, rgba(255,111,174,.18), transparent 60%), radial-gradient(ellipse at 20% -10%, rgba(63,208,201,.12), transparent 55%), linear-gradient(#080c17cc, #0d1424ee); }
h1, h2, h3 { font-family: "IM Fell English SC", Georgia, serif; font-weight: 400; margin: 0 0 .4em; }
h2 small { font-family: "Courier Prime", monospace; font-size: .55em; color: var(--muted); }
.card { position: relative; background: var(--bone); color: var(--ink); padding: 26px 30px 22px; max-width: 620px; width: 100%; border: 2px solid var(--ink);
  border-radius: 3px 5px 4px 6px / 6px 3px 5px 4px; box-shadow: 6px 7px 0 rgba(0,0,0,.55); transform: rotate(-.4deg); }
.card.wide { max-width: 900px; }
.card.memo { background-image: repeating-linear-gradient(transparent 0 31px, rgba(63,120,160,.18) 31px 32px); background-position: 0 14px; }
.small-card { max-width: 320px; text-align: center; }
.tape { position: absolute; top: -12px; left: 50%; width: 120px; height: 26px; margin-left: -60px; background: rgba(255,179,71,.6); transform: rotate(2deg); }
.title-card h1 { font-size: clamp(34px, 7vw, 58px); letter-spacing: .02em; margin-bottom: 0; }
.title-card .sub { margin: 0 0 18px; color: var(--muted); }
.title-card h2 { font-size: 20px; margin-top: 6px; }
.sticker { position: absolute; right: -14px; top: -18px; background: var(--pink); color: var(--ink); font: 700 12px/1.15 "Courier Prime", monospace; text-align: center;
  padding: 12px 10px; border: 2px solid var(--ink); border-radius: 50%; width: 92px; height: 92px; display: flex; align-items: center; justify-content: center; transform: rotate(12deg); box-shadow: 3px 3px 0 var(--ink); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 16px; }
.btn { font: 700 16px "Courier Prime", monospace; color: var(--ink); background: var(--paper2); border: 2px solid var(--ink); border-radius: 4px 2px 5px 3px;
  padding: 10px 16px; min-height: 44px; min-width: 44px; cursor: pointer; position: relative; box-shadow: 3px 3px 0 var(--ink); text-decoration: none; display: inline-block; }
.btn:hover, .btn:focus-visible { background: #fff6dd; outline: 3px solid var(--teal); outline-offset: 2px; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.big { background: var(--sodium); font-size: 19px; }
.btn.tiny { font-size: 12px; padding: 3px 8px; min-height: 34px; box-shadow: 2px 2px 0 var(--ink); }
.mode { font-family: "Bungee", sans-serif; font-size: 30px; text-align: left; padding: 14px 16px; }
.btn.mode { font-size: 30px; }
.mode small { display: block; font: 400 13px "Courier Prime", monospace; margin-top: 4px; }
#m-2d { transform: rotate(.5deg); } #m-3d { transform: rotate(-.6deg); }
.opts { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 15px; }
select { font: 700 15px "Courier Prime", monospace; background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; padding: 4px 6px; min-height: 36px; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; } .check input { width: 20px; height: 20px; accent-color: var(--wine); }
.line { display: flex; gap: 8px; align-items: center; margin: 6px 0; justify-content: space-between; }
.fine { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.hint { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.keys { border-collapse: collapse; font-size: 13px; width: 100%; } .keys td, .keys th { padding: 2px 6px; border-bottom: 1px dashed rgba(0,0,0,.2); text-align: left; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; } .row.center { justify-content: center; }
#scr-pause { background: rgba(8,12,23,.55); }
@media (max-width: 760px) { .cols, .modes { grid-template-columns: 1fr; } .card { padding: 18px 16px; } .btn.mode { font-size: 24px; } }
@media (max-height: 520px) { .title-card h1 { font-size: 30px; } .title-card .sub { margin-bottom: 6px; } .modes { grid-template-columns: 1fr 1fr; margin: 4px 0 8px; } .btn.mode { font-size: 20px; padding: 8px 12px; } .fine { margin-top: 8px; font-size: 12px; } .sticker { width: 70px; height: 70px; font-size: 10px; right: -6px; top: -10px; } }

/* ---------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#proto-tag { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); background: var(--pink); color: var(--ink); font: 700 12px "Courier Prime", monospace;
  padding: 4px 9px; border: 2px solid var(--ink); transform: rotate(-1.5deg); box-shadow: 2px 2px 0 var(--ink); }
#proto-tag span { font-weight: 400; margin-left: 4px; }
#place { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%) rotate(-1deg); font: 22px "IM Fell English SC", serif; color: var(--bone);
  text-shadow: 0 0 10px rgba(255,111,174,.6), 2px 2px 0 #000; opacity: 0; white-space: nowrap; }
#place.show { animation: place 3.6s ease forwards; }
@keyframes place { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
#prompt { position: absolute; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%) rotate(.6deg); background: var(--bone); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); padding: 8px 14px; font: 700 16px "Courier Prime", monospace; white-space: nowrap; }
#prompt kbd { display: inline-block; min-width: 26px; text-align: center; background: var(--sodium); border: 2px solid var(--ink); border-radius: 4px; padding: 0 5px; margin-right: 6px; font: inherit; }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%) rotate(-1deg); background: var(--ink); color: var(--sodium); border: 2px solid var(--sodium); padding: 6px 12px; font: 700 15px "Courier Prime", monospace; }
#lap { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); color: var(--bone); font: 700 14px "Courier Prime", monospace; text-shadow: 1px 1px 0 #000; text-align: right; white-space: pre; margin-right: 52px; }
#speedo { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); width: 180px; transform: rotate(1.2deg); }
#speedo canvas { width: 180px; height: 180px; display: block; }
.jostle { margin-top: 4px; background: var(--bone); color: var(--ink); border: 2px solid var(--ink); padding: 3px 7px 4px; font: 700 11px "Courier Prime", monospace; box-shadow: 3px 3px 0 rgba(0,0,0,.6); }
.jostle span { letter-spacing: .08em; } .jostle b { display: block; font-weight: 400; font-size: 11px; }
.jostle .bar { height: 7px; border: 1.5px solid var(--ink); margin: 2px 0; background: #d9cfb8; }
.jostle .bar i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .15s; }
.jostle .bar i.warm { background: var(--sodium); } .jostle .bar i.hot { background: var(--pink); }
#dbg { position: absolute; left: max(10px, env(safe-area-inset-left)); top: 44px; margin: 0; font: 11px/1.35 "Courier Prime", monospace; color: var(--teal); background: rgba(8,12,23,.65); padding: 4px 6px; }
#pause-btn { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); pointer-events: auto; }

/* ---------- touch controls (only shown on touch devices) */
#touch { position: absolute; inset: 0; pointer-events: none; }
#t-look { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; touch-action: none; }
#t-stick { position: absolute; left: 0; top: 30%; bottom: 0; width: 42%; pointer-events: auto; touch-action: none; }
#t-base { position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; border: 2px dashed rgba(239,230,210,.45); background: rgba(8,12,23,.25);
  transform: translate(40px, 60px); opacity: .55; transition: opacity .15s; }
#t-base.on { opacity: 1; }
#t-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(239,230,210,.85); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
#t-btns { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 66px); grid-auto-rows: 58px; gap: 8px; pointer-events: none; direction: rtl; }
.tbtn { pointer-events: auto; touch-action: none; direction: ltr; font: 700 12px/1.05 "Courier Prime", monospace; color: var(--ink); background: rgba(239,230,210,.82); border: 2px solid var(--ink); border-radius: 12px 9px 13px 10px;
  box-shadow: 2px 3px 0 rgba(0,0,0,.6); padding: 2px; }
.tbtn.down { transform: translate(1px, 2px); box-shadow: 0 1px 0 rgba(0,0,0,.6); background: #fff6dd; }
.tbtn.lit { background: var(--teal); }
.tbtn.act { background: var(--sodium); }
.tbtn[data-act="gas"] { background: rgba(63,208,201,.9); } .tbtn[data-act="brake"] { background: rgba(255,111,174,.9); }
#touch .drive { display: none; } body.driving #touch .drive { display: block; } body.driving #touch .foot { display: none; }
body.touch #speedo { transform: scale(.72) rotate(1.2deg); transform-origin: right top; bottom: auto; top: max(44px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); }
body.touch #lap { display: none; }
body.touch #prompt { bottom: max(18px, env(safe-area-inset-bottom)); font-size: 14px; }
body.touch #place { top: max(44px, env(safe-area-inset-top)); font-size: 18px; }
@media (max-height: 430px) { #t-btns { grid-template-columns: repeat(3, 60px); grid-auto-rows: 50px; gap: 6px; } }

/* Phase C: contract card + dignity / heat */
#contract { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(44px, env(safe-area-inset-top)); width: min(280px, 46vw);
  background: var(--bone); color: var(--ink); border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(0,0,0,.55);
  padding: 8px 10px 10px; font: 700 12px/1.25 "Courier Prime", monospace; transform: rotate(-1.1deg); }
#contract .stamp { display: inline-block; color: var(--wine); border: 2px solid var(--wine); padding: 1px 6px; letter-spacing: .12em; font-size: 10px; margin-bottom: 4px; transform: rotate(-2deg); }
#contract b { display: block; font: 18px "IM Fell English SC", serif; }
#contract span { display: block; color: #5a4a3a; margin: 2px 0 4px; }
#contract em { display: block; color: var(--wine); font-style: normal; letter-spacing: .04em; }
#contract p { margin: 6px 0 0; font-weight: 400; color: #3a3230; }
#carry-meter { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: 200px;
  background: var(--bone); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.55);
  padding: 6px 8px; font: 700 11px/1.2 "Courier Prime", monospace; transform: rotate(.7deg); }
#carry-meter .bar { position: relative; height: 9px; border: 1.5px solid var(--ink); margin: 3px 0 6px; background: #d9cfb8; }
#carry-meter .bar span { position: absolute; left: 4px; top: -12px; font-size: 9px; letter-spacing: .08em; }
#carry-meter .bar i { display: block; height: 100%; width: 100%; background: var(--teal); }
#carry-meter .bar i.warm { background: var(--sodium); } #carry-meter .bar i.hot { background: var(--pink); }
#carry-meter .heat i { background: var(--wine); width: 0; }
#carry-meter b { display: block; font-size: 12px; }
#carry-meter .st { font-weight: 400; color: #5a4a3a; margin-top: 2px; }
body.touch #contract { width: min(220px, 50vw); font-size: 11px; top: max(40px, env(safe-area-inset-top)); }
body.touch #carry-meter { width: 160px; bottom: max(90px, env(safe-area-inset-bottom)); }

/* ---------- online / lobby (Phase D) */
#scr-note, #scr-online, #scr-lobby { background: rgba(8,12,23,.72); }
input#on-code { font: 700 18px "Courier Prime", monospace; letter-spacing: .18em; text-transform: uppercase;
  background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; padding: 6px 10px; width: 8em; color: var(--ink); }
.room-list { list-style: none; padding: 0; margin: 6px 0; max-height: 160px; overflow: auto; }
.room-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,.2); font-size: 14px; }
.room-list .mode-tag { background: var(--teal); color: var(--ink); font: 700 11px "Courier Prime", monospace; padding: 2px 6px; border: 1.5px solid var(--ink); }
.roster { list-style: none; padding: 0; margin: 10px 0; }
.roster li { padding: 6px 8px; margin: 4px 0; background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.roster li.host::after { content: "HOST"; font: 700 11px "Courier Prime", monospace; background: var(--sodium); border: 1.5px solid var(--ink); padding: 1px 5px; }
.roster li.away { opacity: .55; }
.roster li .kick { font-size: 12px; padding: 2px 8px; min-height: 28px; }
#net-tag { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(36px, calc(env(safe-area-inset-top) + 28px));
  background: rgba(8,12,23,.75); color: var(--teal); font: 700 11px "Courier Prime", monospace; padding: 3px 8px; border: 1.5px solid var(--teal); }
#net-tag.warn { color: var(--sodium); border-color: var(--sodium); }
.card-foot { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bone) 30%); padding-top: 10px; margin-top: 8px; }

/* live site: online lobby disabled */
#scr-online[hidden]{display:none!important}
