* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c2118; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #f2eee4; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.dim { color: #b8b1a2; font-size: 0.9em; }
code { background: #0006; padding: 2px 6px; border-radius: 4px; color: #ffd166; }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #1c2118; z-index: 50; transition: opacity .4s; }
#loading.hidden { display: flex !important; opacity: 0; pointer-events: none; }
h1 { font-size: 64px; letter-spacing: 6px; margin: 0; color: #ffdb8c; text-shadow: 0 4px 0 #6b3b1c, 0 8px 24px #000a; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.tag { position: absolute; left: 0; top: 0; font-weight: 700; font-size: 14px; white-space: nowrap; text-shadow: 0 1px 2px #000, 0 0 6px #000a; }
.tag.camp.easy { color: #7ee081; } .tag.camp.mid { color: #ffd166; } .tag.camp.hard { color: #ff7a6b; }
.tag.town { color: #d6f2ff; font-size: 15px; }

#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; background: radial-gradient(ellipse at center, #0000 30%, #000a 100%); }
.card { width: min(640px, 94vw); background: #15120fe6; border: 1px solid #5a4632; border-radius: 14px; padding: 26px 30px; box-shadow: 0 20px 60px #000c; text-align: center; }
.card .sub { margin: 6px 0 18px; color: #cdbf9f; }
.card label { display: block; text-align: left; margin: 10px 0 6px; font-weight: 700; }
.card input { width: 100%; font: inherit; font-size: 18px; padding: 9px 12px; border-radius: 8px; border: 1px solid #6b5a44; background: #0007; color: #fff; margin-top: 6px; }
.classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.classes .cls { display: flex; flex-direction: column; padding: 8px 4px; }
.classes .cls small { color: #b8b1a2; font-size: 12px; }
.card > button.big { width: 100%; margin-top: 10px; }
.card .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.card label.inline { display: inline; margin: 0; font-weight: 400; }
select { font: inherit; background: #0007; color: #fff; border: 1px solid #6b5a44; border-radius: 6px; padding: 4px; }
.status { color: #ffb980; min-height: 1.2em; }

button { font: inherit; font-size: 15px; color: #f7f1e3; background: linear-gradient(#5a4a38, #3e3226); border: 1px solid #7a6449; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover:not([disabled]) { background: linear-gradient(#6d5a43, #4b3c2d); }
button.on { border-color: #ffd166; color: #ffd166; box-shadow: 0 0 0 1px #ffd16655 inset; }
button[disabled] { opacity: .5; cursor: default; }
button.big { font-size: 20px; padding: 12px 18px; }
button.big small { display: block; font-size: 13px; color: #e6dcc6; opacity: .85; }
button.primary { background: linear-gradient(#c0702e, #8a4a1c); border-color: #e09a55; }
button.primary:hover:not([disabled]) { background: linear-gradient(#d47d35, #9a5422); }
button.small { font-size: 13px; padding: 4px 9px; }
button.ready { border-color: #ffd166; color: #ffd166; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 14px #ffd16688; } }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud .panel, #hud button { pointer-events: auto; }
.panel { position: absolute; background: #14110ed9; border: 1px solid #4d3d2c; border-radius: 10px; padding: 12px 14px; box-shadow: 0 6px 24px #0008; }
.panel h3 { margin: 0 0 6px; font-size: 18px; }
.panel h3 span { font-weight: 400; color: #cdbf9f; font-size: 15px; margin-left: 6px; }
.panel p { margin: 6px 0; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tl { top: 14px; left: 14px; width: 330px; }
.tl2 { position: absolute; top: 300px; left: 14px; }
.tl3 { top: 346px; left: 14px; width: 330px; display: flex; flex-direction: column; gap: 5px; }
.tl3 button { text-align: left; }
.tl3 small { color: #b8b1a2; }
.tr { top: 14px; right: 14px; width: 320px; }
.top { top: 14px; left: 50%; transform: translateX(-50%); width: min(820px, 60vw); }
.topbar { top: 14px; left: 50%; transform: translateX(-50%); font-size: 18px; padding: 8px 18px; }
.bottom { bottom: 18px; left: 50%; transform: translateX(-50%); position: absolute; }
.bottom.wide { width: min(900px, 70vw); }
.center { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); text-align: center; }
.center h1 { font-size: 48px; margin-bottom: 12px; }
.center button { margin: 6px; }
.help { bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 14px; padding: 8px 16px; white-space: nowrap; }
#crew ul { list-style: none; padding: 0; margin: 8px 0; }
#crew li { margin: 3px 0; font-size: 15px; }
#crew li i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; }
#crew li i.ai { border: 1px solid #ccc; }
#crew em { color: #ffd166; font-style: normal; }
.scrap { color: #ffd166 !important; float: right; }
.xpbar, .hp { height: 6px; background: #0008; border-radius: 3px; overflow: hidden; }
.xpbar div { height: 100%; background: #ffd166; }
.hp { height: 8px; margin: 6px 0; } .hp div { height: 100%; background: #5ae65a; }
.good { color: #7ee081; } .bad { color: #ff7a6b; } .win { color: #ffd166; }
.manual { color: #8fd3ff; font-weight: 700; }
.squad { align-self: center; color: #cdbf9f; }
#toast { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); background: #000c; padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#toast.show { opacity: 1; }
