:root {
  --ink: #f2e6c8;
  --dim: #b8a888;
  --gold: #ffd27a;
  --good: #8fe08a;
  --bad: #ff8a7a;
  --panel: rgba(28, 22, 18, 0.94);
  --panel2: rgba(48, 38, 30, 0.95);
  --edge: #7a5a32;
  --edge2: #3a2a18;
  --font: 'VT323', 'Courier New', monospace;
}
* { box-sizing: border-box; scrollbar-color: #7a5a32 #1e1610; scrollbar-width: thin; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0a10; color: var(--ink); font-family: var(--font); font-size: 20px; user-select: none; }
canvas#sky { position: fixed; left: 0; top: 0; display: block; pointer-events: none; }
canvas#view { position: fixed; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; display: block; cursor: crosshair; }
.hidden { display: none !important; }
.icon { image-rendering: pixelated; display: block; }
b { color: var(--gold); font-weight: normal; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.dim { color: var(--dim); }
.warn { color: #ff9a5a; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
#hud > div, #hud button, #hud canvas, #hotbar .slot { pointer-events: auto; }
#hud-tl { position: absolute; left: 12px; top: 10px; width: 360px; pointer-events: none !important; }
#hud-tl #goals { max-width: 300px; }
#health { display: flex; align-items: center; gap: 8px; }
#hearts { display: grid; grid-template-columns: repeat(10, 27px); gap: 1px; }
.heart { position: relative; width: 27px; height: 24px; background-size: 100% 100%; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6)); }
.heart-fill { position: absolute; left: 0; top: 0; height: 100%; width: 100%; background-size: 27px 24px; background-repeat: no-repeat; image-rendering: pixelated; }
#hearts.low .heart { animation: heartbeat 0.8s ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.15); } 30% { transform: scale(1); } }
#hp-text { font-size: 17px; color: var(--dim); text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.bar { position: relative; height: 22px; background: #2a1414; border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #c83a3a; transition: width 0.15s; }
.bar span { position: absolute; top: 0; right: 0; bottom: 0; left: 0; text-align: center; line-height: 18px; text-shadow: 1px 1px 0 #000; }
#armor-line { margin-top: 6px; color: #b8d0f0; text-shadow: 1px 1px 0 #000; font-size: 18px; }
#goals { margin-top: 8px; background: rgba(20, 16, 12, 0.7); border: 1px solid #5a4228; padding: 6px 8px; font-size: 17px; line-height: 1.05; }
#goals:empty { display: none; }
.goals-title { color: var(--gold); margin-bottom: 2px; }
.goal { margin: 3px 0; }
.goal .prog { color: var(--gold); }
#hud-top { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); text-align: center; pointer-events: none !important; text-shadow: 1px 1px 0 #000, -1px 0 0 #000; }
#clock { font-size: 24px; background: rgba(20, 16, 12, 0.7); padding: 2px 14px; border: 1px solid #5a4228; display: inline-block; }
#clock.is-night { border-color: #8a3030; background: rgba(40, 10, 16, 0.75); }
#clock .night { color: #ff7a7a; }
#threat { font-size: 17px; margin-top: 3px; color: #d8c8a8; }
#threat i { color: #a0c8ff; font-style: normal; }
#boss { margin-top: 6px; width: 360px; }
#boss .name { color: #ff6a6a; font-size: 20px; }
#boss .bar { height: 12px; }
#boss .fill { background: #b02060; }
#hud-tr { position: absolute; right: 12px; top: 10px; width: 300px; text-align: right; font-size: 17px; text-shadow: 1px 1px 0 #000; pointer-events: none !important; }
#minimap { width: 224px; margin-left: auto; display: block; height: 102px; border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); image-rendering: pixelated; background: #000; cursor: pointer; pointer-events: auto !important; }
#village-line { margin-top: 4px; }
#stock-line { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; background: rgba(20, 16, 12, 0.75); border: 1px solid #5a4228; padding: 0 5px 0 3px; font-size: 17px; pointer-events: auto; }
.chip.good { border-color: #3a6a3a; }
.chip.bad { border-color: #7a3030; color: var(--bad); }
#hud-bottom { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; flex-direction: column; align-items: center; pointer-events: none !important; }
#toasts { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 6px; pointer-events: none; }
.toast { background: rgba(16, 12, 10, 0.82); border: 1px solid #5a4228; padding: 2px 12px; font-size: 19px; text-shadow: 1px 1px 0 #000; max-width: 760px; text-align: center; }
#sel-name { height: 20px; color: var(--gold); text-shadow: 1px 1px 0 #000; font-size: 19px; }
#hotbar { display: flex; gap: 4px; pointer-events: auto; }
.slot { position: relative; width: 46px; height: 46px; background: var(--panel2); border: 2px solid #5a4228; box-shadow: inset 0 0 0 2px #1a120a; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot:hover { border-color: #b08a50; }
.slot.sel { border-color: var(--gold); box-shadow: inset 0 0 0 2px #1a120a, 0 0 8px rgba(255, 210, 122, 0.5); }
.tt-hint { margin-top: 4px; font-size: 14px; color: #ffd27a; }
.slot.fav::after { content: '★'; position: absolute; right: 2px; top: -3px; font-size: 13px; color: #ffd27a; text-shadow: 1px 1px 0 #000; }
.slot .key { position: absolute; left: 3px; top: 0; font-size: 14px; color: var(--dim); }
.slot .n { position: absolute; right: 3px; bottom: -2px; font-size: 17px; text-shadow: 1px 1px 0 #000, -1px 0 0 #000; }
.slot .ghost { color: #6a5a48; font-size: 14px; }
#hud-buttons { display: flex; gap: 4px; margin-top: 6px; pointer-events: auto; }
.hud-btn { font-family: var(--font); font-size: 17px; color: var(--ink); background: var(--panel); border: 1px solid #5a4228; padding: 1px 8px; cursor: pointer; }
.hud-btn:hover { border-color: var(--gold); color: var(--gold); }
.hud-btn .k { color: var(--gold); margin-right: 4px; }
#banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); text-align: center; pointer-events: none !important; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; max-width: 80%; }
.b-title { font-size: 64px; letter-spacing: 2px; }
.b-sub { font-size: 24px; color: var(--ink); }
#mode-hint { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); background: rgba(30, 50, 30, 0.85); border: 1px solid #5a8a5a; padding: 2px 12px; font-size: 19px; pointer-events: none !important; }

#mp-line { margin-top: 4px; font-size: 16px; color: #a0d8ff; }

/* Terraria-style inventory: stays open while you play */
#invbox { position: absolute; left: 12px; top: 64px; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); padding: 6px 8px; pointer-events: auto; max-width: calc(100vw - 260px); }
#craftbox { position: absolute; left: 12px; bottom: 12px; width: 300px; max-height: 34vh; overflow-y: auto; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); padding: 6px 8px; pointer-events: auto; }
.inv-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.inv-top .btn:last-child { margin-left: auto; }
.inv-title { color: var(--gold); font-size: 22px; }
.inv-body { display: flex; gap: 8px; }
.inv-equip { display: flex; gap: 4px; }
.inv-equip .equip-col { display: flex; flex-direction: column; gap: 4px; }
.inv-equip .btn.on { border-color: var(--gold); color: var(--gold); }
.inv-stock { margin-top: 6px; max-width: 520px; }
.inv-stock .stock-list { max-height: 24vh; }
.small { font-size: 15px; }
.craft-search { width: 100%; box-sizing: border-box; margin: 2px 0 4px; padding: 3px 6px; font: inherit; font-size: 16px; color: var(--ink); background: rgba(0, 0, 0, 0.35); border: 2px solid var(--edge); outline: none; }
.craft-search:focus { border-color: var(--gold); }
.craft-grid { display: grid; grid-template-columns: repeat(6, 42px); gap: 3px; margin-top: 4px; }
.craft-grid .slot { width: 42px; height: 42px; }
.slot.craft.no { opacity: 0.4; }
.tt-cost { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0; }

/* chat */
#chat { position: absolute; left: 12px; bottom: 120px; width: 420px; pointer-events: none !important; }
#chatlog { display: flex; flex-direction: column; gap: 1px; }
.chat-line { background: rgba(16, 12, 10, 0.7); padding: 1px 8px; font-size: 18px; text-shadow: 1px 1px 0 #000; }
#chat-input { width: 100%; margin-top: 4px; font-family: var(--font); font-size: 19px; background: rgba(16, 12, 10, 0.92); color: var(--ink); border: 2px solid var(--edge); padding: 2px 8px; pointer-events: auto; }

/* ---------- panels ---------- */
#panel { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(5, 4, 8, 0.45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.paused-tag { margin-left: auto; margin-right: 12px; color: var(--dim); font-size: 16px; letter-spacing: 2px; }
.window { background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 0 0 3px var(--edge2), 0 10px 40px rgba(0, 0, 0, 0.6); width: min(560px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.window.wide { width: min(1040px, 96vw); }
.win-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: linear-gradient(#4a3420, #2e2014); border-bottom: 2px solid var(--edge); font-size: 28px; color: var(--gold); }
.close { font-family: var(--font); background: none; border: 1px solid #6a4a28; color: var(--ink); font-size: 20px; cursor: pointer; width: 32px; height: 30px; }
.close:hover { color: var(--bad); border-color: var(--bad); }
.win-body { padding: 10px 14px; overflow: auto; }
h3 { margin: 4px 0 6px; color: var(--gold); font-weight: normal; font-size: 22px; }
p { margin: 6px 0; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.btn { font-family: var(--font); font-size: 19px; color: var(--ink); background: linear-gradient(#5a4028, #3a2816); border: 2px solid #8a6a3a; padding: 2px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--gold); color: #fff; background: linear-gradient(#6a4c30, #46301a); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { font-size: 16px; padding: 0 8px; }
.btn.tiny { font-size: 14px; padding: 0 4px; border-width: 1px; }
.btn.big { font-size: 26px; padding: 6px 18px; width: 100%; }
.btn.primary { border-color: var(--gold); color: var(--gold); }
.btn.danger { border-color: #9a3a3a; background: linear-gradient(#5a2020, #3a1010); }
.tabs { display: flex; gap: 2px; margin: 4px 0 8px; flex-wrap: wrap; }
.tab { font-family: var(--font); font-size: 19px; background: #2a1e14; color: var(--dim); border: 1px solid #5a4228; padding: 2px 12px; cursor: pointer; }
.tab.on { background: #5a4028; color: var(--gold); border-color: var(--gold); }
.scroll { overflow-y: auto; max-height: 58vh; }
.note { color: var(--dim); padding: 6px; }
select { font-family: var(--font); font-size: 18px; background: #2a1e14; color: var(--ink); border: 1px solid #8a6a3a; }
input[type=range] { width: 220px; }

/* inventory */
.inv { display: grid; grid-template-columns: 150px auto 1fr; gap: 16px; }
.inv-grid { display: grid; grid-template-columns: repeat(9, 46px); gap: 4px; }
.inv-grid .slot.hot { border-color: #7a6a42; }
.equip { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stats { margin-top: 10px; font-size: 18px; }
.help-line { margin-top: 8px; color: var(--dim); font-size: 16px; }
.stock-list { max-height: 46vh; }
.stock-row { display: flex; align-items: center; gap: 6px; padding: 1px 2px; border-bottom: 1px solid #3a2a18; font-size: 18px; }
.stock-row .nm { flex: 1; }
.stock-row b { min-width: 40px; text-align: right; }
#held { position: fixed; pointer-events: none; z-index: 30; }
#held .n { position: absolute; right: -4px; bottom: -6px; text-shadow: 1px 1px 0 #000; }

/* crafting */
.craft-info { color: var(--ink); margin-bottom: 4px; }
.recipes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.recipe { display: flex; align-items: center; gap: 8px; background: rgba(60, 46, 34, 0.5); border: 1px solid #3a2a18; padding: 4px 6px; opacity: 0.75; }
.recipe.ok { opacity: 1; border-color: #5a6a3a; }
.r-icon { position: relative; width: 36px; flex: none; }
.r-icon .n { position: absolute; right: -4px; bottom: -6px; font-size: 15px; text-shadow: 1px 1px 0 #000; }
.r-main { flex: 1; min-width: 0; }
.r-name { font-size: 19px; }
.r-stats { color: #a0c8ff; font-size: 15px; margin-left: 6px; }
.r-cost { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-top: 1px; }
.cost { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.station { font-size: 15px; margin-left: 4px; }
.r-btns { display: flex; flex-direction: column; gap: 2px; }

/* build */
.bgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bcard { background: rgba(60, 46, 34, 0.5); border: 1px solid #5a4228; padding: 8px; display: flex; flex-direction: column; gap: 3px; }
.bcard.locked { opacity: 0.55; }
.b-img { image-rendering: pixelated; height: 72px; object-fit: contain; align-self: center; width: auto; max-width: 100%; }
.b-img.big { height: 140px; }
.b-name { color: var(--gold); font-size: 22px; }
.b-desc { font-size: 16px; color: var(--dim); flex: 1; }
.b-meta { font-size: 15px; }

/* village */
.vlist { max-height: 48vh; }
.vrow { display: grid; grid-template-columns: 110px 150px 120px 1fr; gap: 10px; align-items: center; padding: 3px 4px; border-bottom: 1px solid #3a2a18; }
.vrow.refugee { display: block; background: rgba(40, 60, 80, 0.4); }
.v-name { color: var(--gold); }
.v-bars { display: flex; flex-direction: column; gap: 3px; }
.mini { height: 7px; background: #1a1210; border: 1px solid #4a3828; width: 110px; }
.mini > div { height: 100%; }
.v-status { font-size: 17px; }
.jobs-help { margin-top: 8px; color: var(--dim); }
.jobs-help summary { cursor: pointer; color: var(--ink); }
.keep-view { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
.def-table { border-collapse: collapse; margin: 8px 0; }
.def-table th, .def-table td { border: 1px solid #4a3828; padding: 2px 10px; text-align: center; }
.def-table th { color: var(--gold); font-weight: normal; }
.def-table td.breaks { background: rgba(160, 40, 40, 0.45); }
.def-table tr.grow td { color: #f9a; }
.def-table td.cracks { background: rgba(160, 120, 40, 0.4); }
.def-table td.holds { background: rgba(40, 120, 60, 0.4); }
.defence ul { padding-left: 20px; margin: 4px 0; }

/* building */
.bp-top { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; }
.bpanel .mini { width: 100%; height: 9px; }
.toggles { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.toggle { cursor: pointer; }

/* menus */
.menu { display: flex; flex-direction: column; gap: 8px; min-width: 300px; }
.confirm p { font-size: 22px; }
.install { max-width: 560px; }
.install ol { font-size: 20px; margin: 4px 0 10px; padding-left: 26px; }
.install li { margin: 4px 0; }
.install a.btn { text-decoration: none; display: inline-block; }
.save-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid #3a2a18; padding: 6px 0; }
.settings .setting { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; gap: 20px; }
.help .cols { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; }
.help table td { padding: 2px 6px; vertical-align: top; }
.help td.key { color: var(--gold); white-space: nowrap; }
.help ul { padding-left: 18px; margin: 0; }
.help li { margin-bottom: 6px; }
.changes .upd { margin-bottom: 14px; }
.changes ul { padding-left: 20px; margin: 4px 0; }
.changes li { margin-bottom: 4px; }
/* title screens */
.screen-box { background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 0 0 3px var(--edge2), 0 10px 40px rgba(0, 0, 0, 0.6); padding: 14px 20px; width: min(760px, 94vw); max-height: 90vh; display: flex; flex-direction: column; gap: 6px; }
.screen-box.wide { width: min(940px, 96vw); }
.screen-box h2, .title h2 { margin: 0; color: var(--gold); font-weight: normal; font-size: 40px; }
.card-list { display: flex; flex-direction: column; gap: 6px; max-height: 58vh; }
.card { display: flex; align-items: center; gap: 12px; background: rgba(60, 46, 34, 0.5); border: 1px solid #5a4228; padding: 6px 10px; }
.card.on { border-color: var(--gold); }
.card-main { flex: 1; min-width: 0; }
.card-name { color: var(--gold); font-size: 24px; }
.card-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.create-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.name-input, .seed-input { font-family: var(--font); font-size: 20px; background: #1e1610; color: var(--ink); border: 2px solid #8a6a3a; padding: 3px 8px; }
.name-input { width: 260px; }
.seed-input { width: 150px; }
.name-input.need { border-color: var(--bad); }
.btn.continue { display: flex; flex-direction: column; align-items: center; line-height: 1.05; white-space: normal; font-size: 22px; }
.btn.continue .sub { font-size: 17px; color: var(--ink); }
.row.three .btn { flex: 1; }
/* The small buttons under the big ones on the title screen: two to a row, exactly as wide as the big buttons. */
.menu-small { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu-small .btn { width: 100%; min-width: 0; margin: 0; }
.who { display: flex; align-items: center; gap: 10px; margin-top: 10px; text-shadow: 1px 1px 0 #000; background: rgba(16, 12, 10, 0.6); padding: 4px 14px 4px 4px; border: 1px solid #5a4228; }
.who a, .title a { color: var(--gold); }
.screen-note { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: rgba(60, 20, 10, 0.92); border: 1px solid #a05030; padding: 4px 14px; font-size: 20px; z-index: 30; }
canvas.char-preview { image-rendering: pixelated; background: radial-gradient(ellipse at center 80%, rgba(255, 210, 122, 0.12), transparent 70%); }

/* character editor */
.editor { display: grid; grid-template-columns: 200px 1fr; gap: 18px; }
.ed-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ed-preview canvas { background: linear-gradient(#3a5a8a 0%, #8ac0e8 70%, #4f8a35 70%, #3d6e28 100%); border: 2px solid var(--edge); }
.ed-controls { display: flex; flex-direction: column; gap: 6px; }
.ed-row { display: flex; align-items: center; gap: 10px; }
.ed-label { width: 100px; color: var(--gold); flex: none; }
.swatches, .choices { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.swatch { width: 24px; height: 24px; border: 2px solid #2a1e14; cursor: pointer; padding: 0; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.swatches input[type=color] { width: 30px; height: 26px; padding: 0; border: 1px solid #8a6a3a; background: none; cursor: pointer; }
.choices .btn.on, .row .btn.on { border-color: var(--gold); color: var(--gold); }

/* key bindings */
table.keys { border-collapse: collapse; margin: 4px 0 8px; }
table.keys td { padding: 2px 8px 2px 0; }
.keybtn { min-width: 110px; }
.keybtn.listening { border-color: var(--gold); color: var(--gold); }

.chest-view .inv-grid { margin-bottom: 4px; }
.sugg-list { max-height: 42vh; display: flex; flex-direction: column; gap: 4px; }
.sugg { display: flex; gap: 10px; align-items: flex-start; background: rgba(60, 46, 34, 0.5); border: 1px solid #5a4228; padding: 4px 8px; }
.sugg .vote { min-width: 46px; }
.sugg-text { width: 100%; height: 70px; font-family: var(--font); font-size: 19px; background: #1e1610; color: var(--ink); border: 2px solid #8a6a3a; padding: 4px 8px; resize: vertical; }
.ed-note { grid-column: 1 / -1; margin: 0; }
.bigmap { cursor: grab; }
.bigmap { width: 100%; image-rendering: pixelated; border: 2px solid var(--edge); background: #000; }

/* title & game over */
#screen { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.75)); z-index: 5; }
.title { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title h1 { font-size: 120px; margin: 0; color: var(--gold); letter-spacing: 10px; text-shadow: 4px 4px 0 #5a2a10, 8px 8px 0 rgba(0, 0, 0, 0.6); font-weight: normal; }
.title.gameover h1 { font-size: 72px; color: #ff7a6a; letter-spacing: 3px; }
.tagline { font-size: 28px; text-shadow: 2px 2px 0 #000; margin-bottom: 14px; }
.world-record { font-size: 22px; color: #ffd24a; text-shadow: 2px 2px 0 #000; margin: -6px 0 14px; }
.title .menu { width: 320px; }
.foot { margin-top: 18px; color: var(--dim); font-size: 17px; text-shadow: 1px 1px 0 #000; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 30px; font-size: 22px; margin-bottom: 14px; text-shadow: 1px 1px 0 #000; }

#tooltip { position: fixed; z-index: 40; background: rgba(16, 12, 10, 0.96); border: 2px solid var(--edge); padding: 4px 8px; max-width: 320px; pointer-events: none; font-size: 18px; }
.tt-name { color: var(--gold); font-size: 20px; }
.tt-stats { color: #a0c8ff; }
.tt-desc { color: var(--ink); }

@media (max-width: 900px) {
  html, body { font-size: 17px; }
  .inv { grid-template-columns: 1fr; }
  .recipes, .bgrid { grid-template-columns: 1fr; }
  #hud-tl { width: 220px; }
  .vrow { grid-template-columns: 1fr 1fr; }
  .editor { grid-template-columns: 1fr; }
  #invbox { max-width: calc(100vw - 24px); }
}
.backup-due { color: #ffb070; margin-bottom: 4px; }
/* Touch screens: on-screen buttons, shown once the screen has been touched. */
#touch { display: none; }
body.touch #touch { display: block; }
body.touch canvas#view, #touch button { touch-action: none; }
/* Narrow enough to sit beside the hotbar on a phone held sideways: down above left and right; eat and use
   stacked beside a big jump button. */
#touch-move, #touch-act { position: absolute; bottom: 12px; display: grid; gap: 8px; pointer-events: auto; }
#touch-move { left: 12px; grid-template-columns: 54px 54px; grid-template-areas: 'down down' 'left right'; justify-items: center; }
#touch-move [data-act=down] { grid-area: down; } #touch-move [data-act=left] { grid-area: left; } #touch-move [data-act=right] { grid-area: right; }
#touch-act { right: 12px; grid-template-columns: 54px 72px; grid-template-areas: 'heal jump' 'use jump'; align-items: end; }
#touch-act [data-act=heal] { grid-area: heal; } #touch-act [data-act=interact] { grid-area: use; } #touch-act [data-act=jump] { grid-area: jump; }
#touch button { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(255, 210, 122, 0.55); background: rgba(20, 14, 10, 0.45); color: var(--ink); font: inherit; font-size: 18px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#touch button.big { width: 72px; height: 72px; }
#touch button.on { background: rgba(255, 210, 122, 0.35); }
#hud.inv-open #touch-move { display: none; }
.trash-slot { border-color: #8a3a2a; }
.trash-slot .ghost { color: #c07060; }
/* The tutorial box, on the right under the minimap, clear of the inventory and crafting on the left. */
#tutorial { position: absolute; right: 12px; top: 176px; width: min(380px, calc(100vw - 32px)); background: rgba(20, 16, 12, 0.88); border: 2px solid var(--gold); box-shadow: 0 0 0 2px var(--edge2); padding: 8px 10px; pointer-events: auto; text-shadow: 1px 1px 0 #000; }
#tutorial .tut-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--gold); font-size: 20px; }
#tutorial .tut-text { margin: 4px 0 6px; font-size: 18px; line-height: 1.1; }
#tutorial .row { gap: 6px; }
#tutorial .tut-prog { display: block; margin-top: 2px; color: var(--gold); }
.hud-btn.tut-glow { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 2px var(--gold); animation: tut-glow 0.9s ease-in-out infinite alternate; }
@keyframes tut-glow { from { box-shadow: 0 0 0 1px rgba(255, 210, 122, 0.4); } to { box-shadow: 0 0 6px 3px rgba(255, 210, 122, 0.9); } }
#hud.tutorial-on #goals { display: none; }
#zoom-line { font-size: 15px; color: var(--dim); margin-top: 1px; }
#time-btns { display: flex; justify-content: flex-end; gap: 4px; margin-top: 2px; }
#speed-btn, #skip-btn, #kill-btn { pointer-events: auto; }
#skip-btn.on { border-color: #ffd27a; color: #ffe9a0; }
#speed-btn.fast { border-color: #ffd27a; color: #ffe9a0; box-shadow: 0 0 6px rgba(255, 210, 120, 0.5); }
/* The countdown before a server restart (ui.js restartNotice). */
#restart-notice { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; width: min(460px, calc(100vw - 32px)); background: rgba(40, 14, 10, 0.94); border: 2px solid #ff8a5a; box-shadow: 0 0 0 2px var(--edge2); padding: 10px 12px; color: var(--ink); text-align: center; text-shadow: 1px 1px 0 #000; }
#restart-notice b { display: block; color: #ffb08a; font-size: 22px; margin-bottom: 4px; font-weight: normal; }
#restart-notice .btn { margin-top: 6px; }
/* Shown instead of the game when it is already open in another tab (main.js). */
#one-tab { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #0b0a10; padding: 16px; text-align: center; }
#one-tab > div { max-width: 480px; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); padding: 18px 20px; }
#one-tab h2 { color: var(--gold); margin: 0 0 8px; }
/* Sign-in, username and friends screens. */
.signin-box { max-width: 460px; margin: 10px auto 0; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2); padding: 14px 18px; text-align: center; }
.signin-box h2 { color: var(--gold); margin: 0 0 6px; }
.signin-box .gbtn { display: flex; justify-content: center; min-height: 44px; margin: 10px 0; }
.signin-box .row { justify-content: center; }
.signed-in { margin-top: 10px; color: var(--dim); text-shadow: 1px 1px 0 #000; }
.signed-in b { color: var(--ink); }
.friends-head { color: var(--gold); margin: 8px 0 2px; font-size: 18px; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border: 1px solid #000; }
.dot.on { background: #6ad06a; } .dot.off { background: #6a6a6a; }
.signin-tabs { justify-content: center; }
.signin-fields { display: flex; flex-direction: column; gap: 6px; align-items: center; margin: 8px 0; }
.signin-fields .name-input { width: 240px; }
.signin-box .or { margin-top: 10px; }
/* The title menus, Terraria style: plain words that grow and turn gold under the mouse. */
.tmenu { display: flex; flex-direction: column; align-items: center; gap: 0; margin-top: 8px; }
.tmenu button { background: none; border: none; color: #ece4d2; font: inherit; font-size: 40px; line-height: 1.15; padding: 2px 16px; cursor: pointer; text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; transition: transform 0.08s, color 0.08s; display: flex; flex-direction: column; align-items: center; }
.tmenu button:hover, .tmenu button:focus-visible { color: var(--gold); transform: scale(1.15); outline: none; }
.tmenu .sub { font-size: 17px; color: var(--dim); line-height: 1; }
.title-foot { position: fixed; left: 0; right: 0; bottom: 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 14px; font-size: 21px; color: var(--dim); text-shadow: 1px 1px 0 #000; pointer-events: none; }
.title-foot > div { pointer-events: auto; }
.title-foot .tf-mid { text-align: center; flex: 1; }
.title-foot .tf-mid .foot { margin-top: 0; font-size: 15px; }
.title-foot a { color: var(--ink); }
.credits .credit-list { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 10px; font-size: 24px; text-shadow: 2px 2px 0 #000; }
.credits .credit { display: flex; gap: 14px; justify-content: center; }
.credits .cr-role { color: var(--dim); min-width: 220px; text-align: right; }
.credits .cr-name { color: var(--gold); min-width: 220px; text-align: left; }
.credits .credit-thanks { font-size: 20px; color: var(--ink); margin-bottom: 4px; text-shadow: 2px 2px 0 #000; }
.card.pick { cursor: pointer; }
.card.pick:hover { border-color: var(--gold); }
.nw-form { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 14px; }
.nw-row { display: grid; grid-template-columns: 90px 1fr; gap: 2px 10px; align-items: center; }
.nw-row .nw-label { color: var(--gold); }
.nw-row .small { grid-column: 2; }
@media (max-width: 640px) { .tmenu button { font-size: 32px; } .credits .cr-role, .credits .cr-name { min-width: 0; } .title-foot { flex-direction: column; align-items: center; text-align: center; } }
/* Friends' invites (ui.js showInvite), stacked in the bottom right. */
#invites { position: fixed; right: 14px; bottom: 90px; z-index: 55; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 28px)); }
#invites .invite { background: rgba(14, 24, 34, 0.94); border: 2px solid #6ab0ff; box-shadow: 0 0 0 2px var(--edge2); padding: 8px 10px; color: var(--ink); text-shadow: 1px 1px 0 #000; }
#invites .invite b { color: #9cf; font-weight: normal; }
#invites .row { margin-top: 6px; gap: 6px; }
/* The fox's menu (ui.js p_pet). */
.pet-view { min-width: min(460px, 86vw); }
.pet-xp { position: relative; height: 18px; background: #1a1410; border: 2px solid var(--edge2); margin: 4px 0 8px; }
.pet-xp .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #e8843a; }
.pet-xp span { position: relative; display: block; text-align: center; font-size: 15px; line-height: 14px; text-shadow: 1px 1px 0 #000; }
.pet-up { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--edge2); }
.pet-up .pu-name { color: var(--gold); }
.pet-up .small { grid-column: 1; }
.pet-up .btn { grid-column: 2; grid-row: 1 / span 2; }
.pet-up.locked { opacity: 0.6; }
.pet-pts { color: var(--gold); }
.shop-view { min-width: min(480px, 86vw); }
.shop-row { display: grid; grid-template-columns: 36px 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid var(--edge2); }
.shop-row .nm { color: var(--ink); }
/* The title show's scene caption (ui.js titleCaption). */
#title-caption { position: fixed; left: 0; right: 0; top: 18px; text-align: center; font-size: 26px; color: #ffe9a0; text-shadow: 2px 2px 0 #000; opacity: 0; pointer-events: none; z-index: 5; letter-spacing: 1px; }
#title-caption.show { animation: caption 4.5s ease forwards; }
@keyframes caption { 0% { opacity: 0; transform: translateY(-6px); } 15% { opacity: 1; transform: none; } 100% { opacity: 0.9; } }
#pvp-btn.on { border-color: #ff7a5a; color: #ffb09a; box-shadow: 0 0 6px rgba(255, 90, 60, 0.6); }

/* Phones: a touch screen with little room. The interface is drawn smaller so the world stays in view (the touch
   buttons keep their size), menus scroll when they are taller than the screen, the inventory takes the hotbar's and
   touch buttons' place while open, and a phone held upright is asked to turn sideways (the game waits, alone). */
@media (max-height: 520px), (max-width: 520px) {
  body.touch #screen, body.touch #panel { overflow-y: auto; }
  body.touch #screen > *, body.touch #panel > * { margin: auto; }
  body.touch #hud-tl, body.touch #hud-top, body.touch #hud-tr, body.touch #invbox, body.touch #craftbox, body.touch #chat,
  body.touch #banner, body.touch #mode-hint, body.touch #tutorial, body.touch #panel > *, body.touch #screen > * { zoom: 0.6; }
  body.touch #hud-bottom { zoom: 0.72; }
  body.touch #hud.inv-open #hotbar, body.touch #hud.inv-open #sel-name, body.touch #hud.inv-open #touch { display: none; }
  body.touch #craftbox { max-height: 46vh; }
}
@media (max-height: 340px) { /* the smallest screens (an iPod touch held sideways is 320 tall, less the browser's bars) */
  body.touch #hud-tl, body.touch #hud-top, body.touch #hud-tr, body.touch #invbox, body.touch #craftbox, body.touch #chat,
  body.touch #banner, body.touch #mode-hint, body.touch #tutorial, body.touch #panel > *, body.touch #screen > * { zoom: 0.45; }
  body.touch #hud-bottom { zoom: 0.55; }
  body.touch #touch button { width: 44px; height: 44px; font-size: 15px; }
  body.touch #touch button.big { width: 56px; height: 56px; }
  body.touch #touch-move { grid-template-columns: 44px 44px; } body.touch #touch-act { grid-template-columns: 44px 56px; }
}
body.touch .hud-btn .k, body.touch #tooltip { display: none; }
.tap-modes { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.tap-modes .btn.on { border-color: var(--gold); color: var(--gold); }
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  body.touch #hud:not(.hidden) ~ #rotate { display: flex; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60; align-items: center; justify-content: center; background: rgba(10, 8, 14, 0.94); color: var(--gold); font-size: 28px; text-align: center; padding: 24px; text-shadow: 2px 2px 0 #000; }
}
@media (orientation: portrait) {
  body.touch.in-field #rotate { display: flex; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60; align-items: center; justify-content: center; background: rgba(10, 8, 14, 0.94); color: var(--gold); font-size: 28px; text-align: center; padding: 24px; text-shadow: 2px 2px 0 #000; }
}
/* Browsers without grid (iOS 9): the touch buttons in a row each side instead. */
@supports not (display: grid) {
  #touch-move { display: block; width: 186px; } #touch-act { display: block; width: 210px; text-align: right; }
  #touch button { display: inline-block; margin: 3px; vertical-align: bottom; }
}

/* Messages between friends (ui.js p_dm): theirs on the left, yours on the right. */
.dm { display: flex; flex-direction: column; gap: 6px; min-width: min(520px, 80vw); }
.dm-log { display: flex; flex-direction: column; gap: 4px; height: min(50vh, 420px); overflow-y: auto; padding: 4px; background: rgba(20, 14, 10, 0.5); border: 1px solid #5a4228; }
.dm-msg { align-self: flex-start; max-width: 80%; background: rgba(60, 46, 34, 0.8); border: 1px solid #5a4228; padding: 3px 8px; overflow-wrap: anywhere; }
.dm-msg.mine { align-self: flex-end; background: rgba(90, 70, 30, 0.8); border-color: #a07a3c; }
.dm-input { flex: 1; min-width: 0; }
/* Ranks beside names (ui.js rankBadge). */
.rank.owner { color: #ffd24a; } .rank.op { color: #8fd0ff; }
.online-count { color: #8fe08f; font-size: 20px; text-shadow: 1px 1px 0 #000; margin: -6px 0 10px; min-height: 1em; }
/* Rating the game (ui.js p_rate), and the owner's view of the average. */
.rate .stars { justify-content: center; gap: 6px; margin: 10px 0; }
.btn.star { font-size: 34px; width: 54px; height: 54px; color: #6a5a40; }
.btn.star.on, .btn.star:hover { color: #ffd24a; }
.owner-rating { position: fixed; left: 12px; top: 10px; text-align: left; color: #ffd27a; font-size: 18px; line-height: 1.15; text-shadow: 1px 1px 0 #000; background: rgba(20, 14, 10, 0.55); border: 1px solid #5a4228; padding: 4px 8px; z-index: 6; }
/* The main menu's corner: your account name and skin (ui.js meBadge). */
.me-badge { position: fixed; right: 12px; top: 10px; display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: rgba(20, 14, 10, 0.55); border: 1px solid #5a4228; cursor: pointer; z-index: 6; text-align: left; }
.me-badge:hover { border-color: var(--gold); }
.me-name { color: var(--gold); font-size: 20px; text-shadow: 1px 1px 0 #000; }
/* The worlds menu (ui.js s_worlds, worldThumb). */
.world-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.world-list { gap: 8px; }
.world-card { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 14px; padding: 8px 12px 8px 8px; background: linear-gradient(90deg, rgba(74, 56, 38, 0.75), rgba(46, 34, 24, 0.6)); border: 1px solid #5a4228; box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.06); transition: border-color 0.12s, background 0.12s; }
.world-card.pick { cursor: pointer; }
.world-card.pick:hover { border-color: var(--gold); background: linear-gradient(90deg, rgba(96, 72, 46, 0.85), rgba(58, 42, 28, 0.7)); }
.world-card.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.world-card.fallen { opacity: 0.75; }
.world-thumb { width: 96px; height: 72px; image-rendering: pixelated; border: 2px solid #3a2a1a; box-shadow: 0 0 0 1px #6a5032; }
.world-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.world-name { color: var(--gold); font-size: 26px; line-height: 1; text-shadow: 1px 1px 0 #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-stats { font-size: 18px; }
.world-stats b { color: #f0e0b0; font-weight: normal; }
.world-btns { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.world-btns .btn.play { font-size: 22px; padding: 4px 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 14px; padding: 0 6px; border: 1px solid #6a5032; background: rgba(20, 14, 10, 0.5); color: #d8c8a0; }
.chip.hard { color: #ff8a7a; border-color: #8a3a2a; } .chip.siege { color: #ffb070; border-color: #8a5a2a; } .chip.necro { color: #d0a0ff; border-color: #6a3a8a; }
.chip.cloud { color: #9cd0ff; border-color: #3a5a7a; } .chip.lock { color: #e0d080; }
.world-empty { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
@media (max-width: 640px) { .world-card { grid-template-columns: 72px 1fr; } .world-thumb { width: 72px; height: 54px; } .world-btns { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; } }
.world-empty .btn { width: auto; min-width: 0; padding: 6px 40px; }
.owner-rating .info-head { color: #f0e0b0; font-size: 20px; border-bottom: 1px solid #5a4228; margin-bottom: 2px; }
.owner-rating .gain { color: #a89878; font-size: 15px; } .owner-rating .gain.up { color: #7ee07e; }
/* Siege War's team choice (ui.js p_side). */
.side-pick p { margin: 0 0 10px; }
.side-row { display: flex; gap: 12px; flex-wrap: wrap; }
.side-card { flex: 1 1 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; cursor: pointer; font-family: var(--font); color: var(--ink); background: #2a1e14; background: linear-gradient(color-mix(in srgb, var(--team) 28%, #2a1e14), #2a1e14); border: 2px solid var(--team); }
.side-card:hover { filter: brightness(1.15); }
.side-card img { width: 120px; image-rendering: pixelated; }
.side-name { font-size: 28px; color: var(--team); text-shadow: 1px 1px 0 #000; }
/* Peaceful Building's All items (ui.js p_creative). */
.creative .tabs { flex-wrap: wrap; }
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; max-height: 52vh; margin-top: 6px; }
.creative-item { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: #2a1e14; border: 1px solid #5a4228; cursor: pointer; padding: 0; }
.creative-item:hover { border-color: var(--gold); background: #3a2a1a; }
.creative .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.creative h3 { margin: 10px 0 4px; font-size: 14px; color: var(--gold); }
.creative-mobs { max-height: 50vh; }
.creative-mob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; }
.creative-mob { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; background: #2a1e14; border: 1px solid #5a4228; cursor: pointer; color: inherit; font: inherit; font-size: 11px; }
.creative-mob:hover { border-color: var(--gold); background: #3a2a1a; }
.creative-mob.boss { border-color: #7a3030; }
.mob-pic { width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; }

/* Game Modes (ui.js s_modes). */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.mode-card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; cursor: pointer; font-family: var(--font); color: var(--ink); background: #2a1e14; background: linear-gradient(135deg, color-mix(in srgb, var(--mode) 22%, #2a1e14), #241a12); border: 2px solid #5a4228; border-left: 5px solid var(--mode); transition: border-color 0.12s, transform 0.12s; }
.mode-card:hover { border-color: var(--mode); transform: translateY(-1px); }
.mode-name { font-size: 26px; color: var(--mode); text-shadow: 1px 1px 0 #000; line-height: 1.05; }
.mode-desc { font-size: 17px; line-height: 1.2; }
/* Adventure's Quests (ui.js p_quests). */
.quests { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.quest { padding: 8px 10px; background: #2a1e14; border: 1px solid #5a4228; border-left: 4px solid #6ac8ff; display: flex; flex-direction: column; gap: 3px; }
.quest.main { border-left-color: #ffd24a; background: #33240f; }
.quest-kind { color: #ffd27a; font-size: 20px; }
.quest .btn { align-self: flex-start; margin-top: 4px; }

/* The Realm (ui.js realmPart, p_talk) */
.realm-part h3 { margin: 12px 0 6px; color: var(--gold); }
.realm-places { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.realm-place { display: flex; align-items: center; gap: 8px; padding: 4px 6px; background: rgba(0, 0, 0, 0.2); border: 1px solid #4a3a28; }
.realm-place b { min-width: 120px; }
.realm-place .small { flex: 1; }
.talk p { margin: 6px 0; line-height: 1.5; }

/* Adventure's heroes (ui.js heroBar, p_class, p_hero, p_soul) */
#hero-bar { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 4px; pointer-events: auto; }
.hb-line { font-size: 12px; text-shadow: 0 1px 0 #000; }
.hb-points { color: #ffd27a; }
.hb-xp { width: 260px; height: 5px; background: rgba(0, 0, 0, 0.55); border: 1px solid #2a4a6a; }
.hb-xp-fill { height: 100%; background: linear-gradient(90deg, #3a8aff, #9ad8ff); }
.hb-abilities { display: flex; gap: 4px; }
.hb-ab { position: relative; min-width: 84px; padding: 2px 6px; background: rgba(10, 18, 34, 0.85); border: 1px solid #3a6aa0; font-size: 11px; display: flex; gap: 4px; align-items: center; overflow: hidden; }
.hb-ab.locked { opacity: 0.45; }
.hb-ab .k { color: #9ad8ff; font-weight: bold; }
.hb-ab .cd { position: absolute; left: 0; bottom: 0; width: 100%; height: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.system { border: 1px solid #3a8aff; box-shadow: 0 0 12px rgba(58, 138, 255, 0.45) inset; padding: 8px 10px; background: rgba(8, 16, 32, 0.6); }
.system h3 { color: #9ad8ff; margin: 10px 0 4px; font-size: 14px; }
.sys-head .hb-xp { width: 100%; margin: 4px 0; }
.sys-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(58, 138, 255, 0.15); }
.sys-row b { min-width: 110px; }
.sys-row .sys-val { min-width: 36px; color: #ffd27a; }
.sys-row .small { flex: 1; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.class-card { text-align: left; padding: 10px; background: #1a1410; border: 2px solid var(--cls); color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.class-card:hover { background: #2a2018; box-shadow: 0 0 10px var(--cls); }
.class-name { font-size: 18px; color: var(--cls); font-weight: bold; }
.class-abs { display: flex; flex-direction: column; gap: 3px; }
.mode-card.main { box-shadow: 0 0 14px var(--mode); }
.mode-badge { align-self: flex-start; font-size: 10px; padding: 1px 6px; background: var(--mode); color: #0c0a10; font-weight: bold; margin-bottom: 4px; }

.sys-row .btn { flex: 0 0 auto; width: auto; min-width: 64px; }

.quest.clickable, .goal.clickable { cursor: pointer; }
.quest.clickable:hover { filter: brightness(1.15); }
.quest.open { outline: 1px solid #ffd27a; }
.quest-help { margin-top: 4px; padding: 4px 6px; background: rgba(0, 0, 0, 0.25); }
.goal.path { color: #9ad8ff; }
#goals { pointer-events: auto; }

/* The main screen, like Arcane Legends' hero select: a bar across the top, the heroes standing in the scene (the picked one
   on a glowing ring), and a bar across the bottom with the ways to play. No box: the town shows through. */
.al-main { position: fixed; inset: 0; width: auto; max-width: none; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; background: radial-gradient(ellipse 55% 40% at 50% 52%, rgba(10, 6, 3, 0.62), rgba(10, 6, 3, 0.3) 60%, rgba(10, 6, 3, 0) 100%); border: none; box-shadow: none; }
.al-bar { display: flex; align-items: center; gap: 18px; padding: 10px 24px; background: linear-gradient(180deg, rgba(14, 9, 5, 0.92), rgba(14, 9, 5, 0.55) 80%, rgba(14, 9, 5, 0)); border-bottom: 2px solid rgba(200, 160, 80, 0.35); }
.al-logo { font-size: 50px; color: var(--gold); letter-spacing: 5px; text-shadow: 3px 3px 0 #5a2a10, 5px 5px 0 rgba(0, 0, 0, 0.6); }
.al-bar .online-count { margin: 0; white-space: nowrap; font-size: 18px; }
.al-tops { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.al-top { font-family: var(--font); font-size: 19px; color: var(--ink); background: rgba(40, 30, 20, 0.85); border: 2px solid #6a5032; padding: 6px 14px; cursor: pointer; }
.al-top:hover { border-color: var(--gold); color: var(--gold); }
.al-main .tagline { margin: auto 0 6px; font-size: 32px; text-shadow: 2px 2px 0 #000, 0 0 12px rgba(0, 0, 0, 0.8); }
.hero-row { display: flex; gap: 22px; justify-content: center; align-items: flex-end; flex-wrap: wrap; padding: 0 12px; margin-bottom: auto; }
.hero-card { position: relative; width: 150px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 0 4px; cursor: pointer; font-family: var(--font); color: var(--ink); background: none; border: none; transition: transform 0.15s, filter 0.15s; filter: brightness(0.78); }
.hero-card::before { content: ''; position: absolute; left: 50%; top: 166px; width: 120px; height: 30px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 70%); }
.hero-card:hover { filter: brightness(1); transform: translateY(-3px); }
.hero-card.on { filter: brightness(1.08); transform: translateY(-6px) scale(1.08); }
.hero-card.on::before { background: radial-gradient(ellipse, color-mix(in srgb, var(--mode, #c8a050) 85%, #fff) 0%, color-mix(in srgb, var(--mode, #c8a050) 45%, transparent) 45%, rgba(0, 0, 0, 0) 72%); box-shadow: 0 0 22px color-mix(in srgb, var(--mode, #c8a050) 60%, transparent); }
.hero-card canvas.hero-portrait { position: relative; width: 128px; height: 176px; image-rendering: pixelated; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6)); }
.hero-name, .hero-cls, .hero-lv { position: relative; text-shadow: 2px 2px 0 #000, 0 0 6px #000; }
.hero-name { font-size: 21px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.hero-cls { font-size: 17px; color: var(--mode, var(--gold)); }
.hero-lv { font-size: 15px; color: #d8ccb4; }
.hero-card.on .hero-name { color: var(--gold); }
.hero-card.new { filter: none; opacity: 0.8; justify-content: flex-end; }
.hero-card.new:hover { opacity: 1; }
.hero-plus { width: 96px; height: 150px; display: flex; align-items: center; justify-content: center; font-size: 64px; color: var(--gold); border: 3px dashed rgba(200, 160, 80, 0.6); border-radius: 48px 48px 10px 10px; background: rgba(14, 9, 5, 0.45); line-height: 1; text-shadow: 2px 2px 0 #000; }
.al-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 16px 52px; background: linear-gradient(0deg, rgba(14, 9, 5, 0.92), rgba(14, 9, 5, 0.6) 75%, rgba(14, 9, 5, 0)); border-top: 2px solid rgba(200, 160, 80, 0.35); }
.al-play { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.al-btn { min-width: 210px; display: flex; flex-direction: column; align-items: center; padding: 10px 20px; cursor: pointer; font-family: var(--font); font-size: 27px; color: var(--ink); background: rgba(40, 30, 20, 0.95); border: 2px solid #6a5032; }
.al-btn .sub { font-size: 15px; color: var(--dim); }
.al-btn:hover { border-color: var(--gold); color: var(--gold); }
.al-btn.primary { background: linear-gradient(180deg, #5a8a2a, #3a6a1a); border-color: #9ad06a; color: #fff; text-shadow: 2px 2px 0 #1a3a0a; white-space: nowrap; }
.al-btn.primary .sub { color: #d8f0c0; }
.al-btn.primary:hover { border-color: #ffffff; color: #fff; }
.al-btn:disabled { opacity: 0.5; cursor: default; }
.al-small { font-size: 15px; color: var(--dim); text-shadow: 1px 1px 0 #000; }
.al-small a { color: var(--dim); }
@media (max-width: 640px) {
  .al-bar { flex-wrap: wrap; justify-content: center; gap: 8px; padding: 8px; } .al-logo { font-size: 32px; } .al-bar .online-count { font-size: 15px; } .al-tops { margin: 0; justify-content: center; } .al-top { font-size: 16px; padding: 4px 9px; }
  .al-main .tagline { font-size: 24px; } .hero-row { gap: 4px; } .hero-card { width: 96px; } .hero-cls { font-size: 14px; } .hero-lv { font-size: 12px; white-space: nowrap; } .hero-card::before { top: 84px; width: 70px; height: 20px; } .hero-card canvas.hero-portrait { width: 64px; height: 88px; } .hero-name { font-size: 15px; max-width: 94px; }
  .hero-plus { width: 64px; height: 100px; font-size: 40px; } .al-foot { padding: 10px 8px 148px; } .al-btn { min-width: 0; flex: 1; font-size: 19px; padding: 7px; } .al-play { width: 100%; gap: 6px; }
}

.keys td.keys-head { color: var(--gold); padding-top: 10px; font-size: 0.95em; }
.al-open { font-size: 16px; color: #e8d8b8; text-shadow: 1px 1px 0 #000; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.al-open input { width: 18px; height: 18px; accent-color: #6a9a3a; }
