/* Verachill UI. Layout: full-bleed game canvas, DOM HUD pinned to corners,
   parchment dialogue at the bottom. Navy + gold from the Veracross mark. */
:root {
  --navy: #00345b;
  --deep: #001c33;
  --blue: #2c6c9e;
  --sky: #9cc4e4;
  --stone: #dbe8f3;
  --gold: #f5b82e;
  --gold-d: #c98a12;
  --parch: #f6efdc;
  --parch-d: #e6d8b4;
  --ink: #001c33;
  --heart: #e5484d;
  --ok: #2fb36b;
  --px: "Pixelify Sans", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--deep); color: var(--stone); font-family: var(--px); -webkit-font-smoothing: antialiased; touch-action: none; user-select: none; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.pix { image-rendering: pixelated; }
kbd { font-family: var(--px); font-size: .8em; padding: 0 .35em; border: 1px solid currentColor; border-bottom-width: 2px; border-radius: 3px; opacity: .85; }
button { font-family: var(--px); cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#game { position: fixed; inset: 0; display: block; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 22px; color: var(--gold); background: var(--deep); z-index: 50; }
#loading[hidden] { display: none; }

.panel { background: var(--navy); border: 3px solid var(--deep); box-shadow: inset 0 0 0 2px var(--blue), inset 0 0 0 4px var(--navy), 0 4px 0 rgba(0,0,0,.35); border-radius: 6px; }
.parchment { background: var(--parch); color: var(--ink); box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 4px var(--parch), inset 0 -6px 0 4px var(--parch-d), 0 5px 0 rgba(0,0,0,.35); }

/* ---------------- title ---------------- */
#title { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: auto; padding: 16px; }
#title[hidden] { display: none; }
#title-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }
.title-wrap { width: min(920px, 100%); display: grid; gap: 14px; }
.logo { text-align: center; text-shadow: 0 4px 0 var(--deep), 0 0 24px rgba(0,28,51,.6); }
.logo h1 { margin: 0; font-size: clamp(48px, 9vw, 96px); font-weight: 700; letter-spacing: .02em; color: #fff; line-height: .95; }
.logo h1 span { color: var(--gold); }
.logo p { margin: 6px 0 0; font-size: clamp(16px, 2.4vw, 22px); color: var(--parch); }
.select { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; padding: 16px; }
.roster-wrap { display: grid; align-content: start; gap: 10px; min-width: 0; }
.roster-title { margin: 0; color: var(--gold); font-size: 22px; }
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-content: start; }
.roster button { background: var(--stone); border: 2px solid var(--deep); border-radius: 6px; padding: 6px 2px 4px; color: var(--navy); box-shadow: inset 0 -3px 0 #b9cde0; display: grid; justify-items: center; gap: 2px; font-size: 13px; transition: transform .1s; }
.roster button canvas { width: 64px; height: 64px; }
.roster button:hover { transform: translateY(-2px); border-color: var(--sky); }
.roster button[aria-selected="true"] { border-color: var(--deep); background: var(--parch); box-shadow: 0 0 0 3px var(--gold), inset 0 -3px 0 var(--parch-d); color: var(--deep); font-weight: 600; }
.pick { display: grid; align-content: start; gap: 6px; min-width: 0; }
#pick-big { width: 128px; height: 128px; justify-self: center; background: radial-gradient(circle at 50% 55%, var(--stone) 0 62%, transparent 63%); border-radius: 50%; }
.pick h2 { margin: 0; text-align: center; color: var(--gold); font-size: 26px; }
#join { display: grid; gap: 4px; }
#join label { font-size: 14px; color: var(--sky); margin-top: 4px; }
#join label small { color: var(--stone); opacity: .7; }
#join input { font: 18px var(--px); padding: 8px 10px; border-radius: 4px; border: 2px solid var(--deep); background: var(--parch); color: var(--ink); }
#play { margin-top: 10px; font-size: 20px; font-weight: 600; padding: 10px; border-radius: 6px; border: 3px solid var(--deep); background: var(--gold); color: var(--deep); box-shadow: inset 0 -4px 0 var(--gold-d); }
#play:hover { filter: brightness(1.08); }
#play:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--gold-d); }
.netnote { font-size: 13px; color: var(--sky); margin: 4px 0 0; min-height: 1.2em; }
.neterr { font-size: 14px; color: #ffd9a8; background: rgba(120,40,0,.35); border-radius: 5px; padding: 6px 8px; margin: 6px 0 0; }
#recover { margin-top: 8px; font-size: 14px; }
#recover summary { cursor: pointer; color: var(--sky); }
.recovery { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,12,24,.6); padding: 16px; }
.recovery .sheet { width: min(520px, 100%); padding: 18px 22px; display: grid; gap: 10px; }
.recovery h2 { margin: 0; color: var(--navy); font-size: 26px; }
.recovery p { margin: 0; color: #3d5a73; }
.recovery code { display: block; padding: 10px 12px; background: #fff8e6; border: 2px dashed var(--navy); border-radius: 6px; color: var(--navy); font-size: 20px; text-align: center; word-break: break-all; user-select: all; }
.recovery .row { display: flex; gap: 8px; justify-content: flex-end; }
.recovery button { background: var(--navy); color: #fff; border: 2px solid var(--deep); border-radius: 5px; padding: 6px 12px; font-size: 16px; }
.keys { text-align: center; font-size: 14px; color: var(--parch); text-shadow: 0 2px 0 var(--deep); margin: 0; }
@media (max-width: 700px) {
  .select { grid-template-columns: 1fr; }
  .roster { grid-template-columns: repeat(4, 1fr); }
  .roster button canvas { width: 48px; height: 48px; }
  .roster button span { font-size: 11px; }
  .keys { display: none; }
}

/* ---------------- HUD ---------------- */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
#ui [hidden] { display: none !important; }
#hud { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; display: grid; gap: 6px; justify-items: end; pointer-events: none; }
#hud .clock { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; color: #fff; }
#hud .dial { width: 44px; height: 22px; border-radius: 44px 44px 0 0; background: linear-gradient(#7cc0ec, #f5b82e 140%); position: relative; overflow: hidden; border: 2px solid var(--deep); border-bottom: 0; }
#hud .dial.night { background: linear-gradient(#0b2a52, #2c6c9e 160%); }
#hud .sun { position: absolute; left: 50%; bottom: -1px; width: 2px; height: 20px; transform-origin: 50% 100%; }
#hud .sun::after { content: ""; position: absolute; top: -2px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ffe15a; box-shadow: 0 0 6px #ffe15a; }
#hud .dial.night .sun::after { background: #f6efdc; box-shadow: 0 0 6px #fff; }
#hud .ct { display: grid; line-height: 1.1; text-align: right; }
#hud .day { font-size: 14px; color: var(--sky); }
#hud .time { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
#hud .wx { font-size: 13px; color: var(--gold); }
#hud .points { padding: 4px 12px; font-size: 16px; color: #fff; }
#hud .points .coin { color: var(--gold); }
#hud .points small { color: var(--sky); }

#who { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px; padding: 8px 12px; font-size: 14px; max-width: 240px; }
#who .status { color: var(--sky); font-size: 13px; margin-bottom: 2px; }
#who ul { list-style: none; margin: 0; padding: 0; }
#who li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#who li.me { color: var(--gold); }
#who li small { color: var(--sky); opacity: .8; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 4px; }
.dot.reconnecting { background: var(--gold); } .dot.offline { background: var(--heart); } .dot.solo { background: var(--sky); }

#area-title { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); font-size: clamp(22px, 4vw, 36px); font-weight: 700; color: #fff; text-shadow: 0 3px 0 var(--deep), 0 0 18px var(--deep); opacity: 0; pointer-events: none; white-space: nowrap; }
#area-title.show { animation: areaIn 2.6s ease forwards; }
@keyframes areaIn { 0% { opacity: 0; transform: translate(-50%, 8px); } 15%, 70% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

#toasts { position: absolute; top: 110px; right: 10px; display: grid; gap: 6px; justify-items: end; pointer-events: none; }
.toast { background: var(--parch); color: var(--ink); border: 2px solid var(--deep); border-radius: 5px; padding: 6px 12px; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.3); animation: tIn .25s ease; max-width: 320px; }
.toast.quest { background: var(--gold); } .toast.done { background: var(--ok); color: #fff; } .toast.heart { color: var(--heart); } .toast.points { background: var(--navy); color: var(--gold); }
.toast.out { opacity: 0; transform: translateX(20px); transition: .5s; }
@keyframes tIn { from { opacity: 0; transform: translateX(20px); } }

#prompt { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); background: rgba(0,28,51,.85); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 16px; opacity: 0; transition: opacity .15s; pointer-events: none; white-space: nowrap; }
#prompt.show { opacity: 1; }
#prompt kbd { color: var(--gold); }

#hotbar { position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; }
#hotbar .slot { width: 44px; height: 44px; background: var(--deep); border: 2px solid var(--blue); border-radius: 4px; display: grid; place-items: center; position: relative; }
#hotbar .slot canvas { width: 36px; height: 36px; }
#hotbar .n { position: absolute; right: 2px; bottom: 0; font-size: 13px; color: #fff; text-shadow: 1px 1px 0 var(--deep); }

#emotes { position: absolute; left: 10px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 4px; }
#emotes button, #menu button { background: var(--navy); color: #fff; border: 2px solid var(--deep); box-shadow: inset 0 -3px 0 var(--deep); border-radius: 5px; font-size: 16px; min-width: 34px; height: 34px; padding: 0 8px; }
#emotes button:hover, #menu button:hover { background: var(--blue); }
#menu { position: absolute; right: 10px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 4px; }
#menu kbd { color: var(--gold); border-color: var(--gold); }
#btn-mute.off { text-decoration: line-through; opacity: .6; }

#chat { position: absolute; left: 10px; bottom: 60px; width: min(380px, calc(100% - 20px)); pointer-events: none; }
#chat .log { max-height: 160px; overflow: hidden; display: grid; gap: 2px; font-size: 15px; }
#chat .line { background: rgba(0,28,51,.7); padding: 2px 8px; border-radius: 3px; justify-self: start; color: #fff; transition: opacity 1s; }
#chat .line b { color: var(--gold); font-weight: 600; }
#chat .line.old { opacity: 0; }
#ui.chatting #chat .line.old { opacity: 1; }
#chat input { display: none; width: 100%; margin-top: 4px; font: 16px var(--px); padding: 8px; border-radius: 4px; border: 2px solid var(--gold); background: var(--parch); color: var(--ink); pointer-events: auto; }
#ui.chatting #chat input { display: block; }

#dialogue { position: absolute; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(760px, calc(100% - 20px)); min-height: 140px; display: flex; gap: 14px; padding: 16px 18px; cursor: pointer; z-index: 3; }
#dialogue .portrait { flex: none; width: 112px; height: 112px; background: var(--navy); border: 3px solid var(--deep); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--gold); display: grid; place-items: center; overflow: hidden; }
#dialogue .portrait canvas { width: 96px; height: 96px; }
#dialogue .body { flex: 1; min-width: 0; position: relative; }
#dialogue .name { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
#dialogue .name small { font-size: 14px; color: var(--blue); font-weight: 500; margin-left: 6px; }
#dialogue .text { font-size: 20px; line-height: 1.35; min-height: 3.6em; }
#dialogue .more { position: absolute; right: 0; bottom: -6px; color: var(--gold-d); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
.hearts { color: var(--heart); font-size: 15px; letter-spacing: 1px; margin-left: 8px; }
.hearts i { color: #c8b99a; font-style: normal; }
@media (max-width: 560px) { #dialogue .portrait { width: 72px; height: 72px; } #dialogue .portrait canvas { width: 64px; height: 64px; } #dialogue .text { font-size: 17px; } }

.modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,12,24,.5); padding: 16px; z-index: 4; }
.modal .sheet { width: min(820px, 100%); max-height: calc(100% - 40px); overflow: auto; padding: 18px 22px; display: grid; gap: 8px; }
.modal h2 { margin: 0; color: var(--navy); font-size: 28px; }
.modal h3 { margin: 6px 0 4px; color: var(--blue); font-size: 18px; }
.modal .sub { margin: 0; color: #3d5a73; }
.modal .close { justify-self: end; background: var(--navy); color: #fff; border: 2px solid var(--deep); border-radius: 5px; padding: 6px 12px; font-size: 16px; }
#board .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { #board .cols { grid-template-columns: 1fr; } }
#board ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.note { background: #fffaf0; border: 2px solid var(--parch-d); border-radius: 3px; padding: 8px 10px; box-shadow: 2px 3px 0 rgba(0,0,0,.12); }
#board .note:nth-child(odd) { transform: rotate(-.6deg); } #board .note:nth-child(even) { transform: rotate(.5deg); }
.note.act { border-color: var(--gold); }
.note b { display: block; font-size: 17px; color: var(--navy); }
.note .from { font-size: 13px; color: var(--blue); }
.note p { margin: 4px 0 0; font-size: 15px; line-height: 1.3; }
.note .hint { color: var(--gold-d); }
.empty { color: #6b7f90; font-size: 15px; }
#log .task { border-left: 4px solid var(--gold); padding: 2px 10px; margin-bottom: 6px; }
#log .task p { margin: 2px 0 0; color: #3d5a73; }
#log .donecount { font-size: 14px; color: var(--ok); }
#log .friends { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }
#log .friend { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--parch-d); }

#touch { display: none; }
#ui.touch #touch { display: block; }
#touch .stick { position: absolute; left: 18px; bottom: 90px; width: 120px; height: 120px; border-radius: 50%; background: rgba(0,28,51,.35); border: 2px solid rgba(156,196,228,.5); touch-action: none; }
#touch .knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(245,184,46,.8); border: 2px solid var(--deep); }
#touch .act { position: absolute; right: 22px; bottom: 100px; width: 70px; height: 70px; border-radius: 50%; background: var(--gold); border: 3px solid var(--deep); font-size: 24px; font-weight: 700; color: var(--deep); touch-action: none; }
#touch .jump { position: absolute; right: 104px; bottom: 70px; width: 56px; height: 56px; border-radius: 50%; background: rgba(156,196,228,.9); border: 3px solid var(--deep); font-size: 22px; font-weight: 700; color: var(--deep); touch-action: none; }
#ui.touch #emotes { display: none; }
@media (prefers-reduced-motion: reduce) { #dialogue .more, #area-title.show { animation: none; } }

#map .sheet { width: min(1000px, 100%); }
#map .mapwrap { display: grid; place-items: center; }
#map canvas { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; border: 3px solid var(--deep); border-radius: 4px; }
#map .legend { margin: 0; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--deep); vertical-align: -1px; margin-right: 2px; }
.lg.me { background: var(--heart); } .lg.fr { background: #fff; } .lg.q { background: var(--gold); } .lg.t { background: var(--ok); }
@media (max-width: 700px) {
  #menu { top: calc(76px + env(safe-area-inset-top, 0px)); left: 10px; right: auto; bottom: auto; }
  #menu kbd { display: none; }
  #menu button { height: 30px; font-size: 14px; }
  #who { font-size: 12px; padding: 6px 10px; max-width: 46vw; }
  #hud .clock { padding: 6px 10px 6px 8px; gap: 8px; }
  #hud .time { font-size: 18px; }
  #toasts { top: 120px; left: 10px; right: 10px; }
  .toast { font-size: 13px; }
  #hotbar .slot { width: 34px; height: 34px; }
  #hotbar .slot canvas { width: 28px; height: 28px; }
  #hotbar .slot:nth-child(n+7) { display: none; }
  #prompt { bottom: 76px; font-size: 14px; }
  #chat { bottom: 230px; }
}
#ui.touch #prompt kbd { display: none; }

/* ---------------- Kiosk ---------------- */
body.kiosk { cursor: none; }
#ui.kiosk #who, #ui.kiosk #hud .points, #ui.kiosk #prompt, #ui.kiosk #hotbar, #ui.kiosk #emotes, #ui.kiosk #menu, #ui.kiosk #touch, #ui.kiosk #chat input { display: none; }
#kiosk-banner { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; max-width: calc(100% - 32px); padding: 2px 14px 2px 6px; background: rgba(0,28,51,.82); border: 2px solid var(--deep); border-radius: 20px; color: #fff; font-size: 16px; white-space: nowrap; pointer-events: none; }
#kiosk-banner canvas { width: 32px; height: 32px; margin: -4px 0; }
#kiosk-banner .lbl { color: var(--sky); font-size: 14px; }
#kiosk-banner .name { color: var(--gold); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
#kiosk-banner .where { color: var(--sky); opacity: .8; font-size: 14px; }
#kiosk-banner.in { animation: kioskIn .6s ease; }
@keyframes kioskIn { from { opacity: 0; transform: translate(-50%, -8px); } }
