:root {
  --wood: #3b2716;
  --wood-dark: #1f140a;
  --wood-light: #5c3d22;
  --parch: #ecdcb2;
  --parch-dark: #c9b27e;
  --gold: #f0c24a;
  --gold-dark: #a77b17;
  --ink: #2a1c0f;
  --hp: #c8302a;
  --mp: #2f6fd8;
  --xp: #b77ce8;
  --ok: #57b04a;
  --text: #f4e8cc;
  --muted: #bba982;
  --serif: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --title: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  /* Dark carved wood: plank grain over a warm vertical gradient. */
  --wood-tex: linear-gradient(rgba(44,29,15,.96), rgba(28,18,9,.96));
  --parch-tex: linear-gradient(#efe0b8, #d8c28c);
  --rim: 0 0 0 2px var(--gold-dark), 0 0 0 3px #000, 0 10px 30px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0d1a22; color: var(--text);
  font-family: var(--serif); user-select: none; font-variant-numeric: lining-nums; font-size: 15px;
}
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; cursor: url(../assets/ui/cursor_move.png) 2 2, default; }
/* While the sprite set loads the canvas stays hidden and a short note sits behind the menu. */
#loading { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; padding-bottom: 6vh; background: #0b1216; color: var(--muted); font-size: 15px; z-index: 10; }
html.assets-loading #loading { display: flex; }
/* Fallback until renderer.resize() sets the exact pixel size; no page zoom or scroll gesture on
   the playing field (two fingers zoom the game, see input.js). */
@supports (height: 100dvh) { canvas#game { height: 100dvh; } }
canvas#game { touch-action: none; }
body { touch-action: pan-x pan-y; }
/* Notes for the menu sit at the top of the screen (they ended up below the fold further down). */
#menu-error:not(.hidden), #connect-error:not(:empty) {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 70;
  max-width: calc(100vw - 32px); margin: 0; padding: 8px 14px; border-radius: 10px; text-align: center;
  background: rgba(30, 18, 8, .94); border: 2px solid #2b1a0e; box-shadow: 0 6px 18px rgba(0,0,0,.5); cursor: pointer;
}
#menu-error .btn { margin-left: 8px; cursor: pointer; }
/* Guests: the host went quiet (p2p.js onStall). */
.net-stall { position: fixed; top: calc(52px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 45;
  max-width: calc(100vw - 32px); padding: 6px 14px; border-radius: 10px; background: rgba(30, 18, 8, .92); color: #ffd43a; border: 2px solid #2b1a0e; text-align: center; pointer-events: none; }
/* keep the logo clear of the home/lang chip row */
html.assets-loading canvas#game { visibility: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #ff8a7a; min-height: 1.2em; margin-top: 8px; }
h1, h2, h3, h4 { font-family: var(--title); font-weight: 700; }

/* Iron corner brackets for framed boxes. */
.ornate { position: relative; }
.ornate::after { display: none; }

button { font-family: var(--serif); }
.btn {
  background: linear-gradient(#7a5530, #4a2f17); color: var(--text); border: 2px solid var(--gold-dark);
  border-radius: 6px; padding: 7px 14px; font-size: 15px; cursor: pointer; text-shadow: 0 1px 0 #000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 4px rgba(0,0,0,.5);
}
.btn:hover:not(:disabled) { border-color: var(--gold); filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-family: var(--title); font-size: 18px; padding: 11px 22px; letter-spacing: .5px; }
.btn.tiny { padding: 2px 8px; font-size: 14px; }
.btn.active { border-color: var(--gold); background: linear-gradient(#9b6c37, #5f3c1a); }
/* Parchment plaques with old lettering, nailed to the wood. */
.plaque { background: var(--parch-tex); color: var(--ink); border: 2px solid var(--gold-dark); font-weight: 700; }
.plaque:hover:not(:disabled) { border-color: var(--gold); filter: brightness(1.05); }
.plaque.active { background: linear-gradient(#ffe9a8, #e2bd5e); border-color: var(--gold); }
.plaque:disabled { opacity: .55; }

.panel {
  background: var(--wood-tex);
  border: 3px solid var(--gold-dark); border-radius: 10px;
  box-shadow: 0 0 0 2px #000, 0 10px 40px rgba(0,0,0,.7); padding: 18px 22px;
}
.screen { position: fixed; inset: 0; display: flex; align-items: safe center; justify-content: center; z-index: 20; overflow: auto; }
.menu-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(36,19,7,.2), rgba(24,12,4,.78));
}
.menu-panel { position: relative; width: min(470px, 92vw); text-align: center; }
.panel.wide { position: relative; width: min(1100px, 96vw); max-height: 92vh; overflow: auto; }
.panel.wide h2 { color: var(--gold); margin: 0 0 12px; }
.logo {
  font-size: 54px; margin: 6px 0 0; color: var(--gold); letter-spacing: 2px;
  text-shadow: 0 3px 0 #6b4a10, 0 6px 14px #000;
}
.sublogo { font-size: 22px; color: var(--parch); font-style: italic; margin-bottom: 6px; }
.tagline { color: var(--muted); margin: 4px 0 16px; }
.field { display: flex; flex-direction: column; text-align: left; gap: 4px; margin: 8px 0; font-size: 14px; color: var(--muted); }
.field input, .field select {
  font-family: var(--serif); font-size: 16px; padding: 7px 9px; background: var(--parch-tex); color: var(--ink);
  border: 2px solid var(--gold-dark); border-radius: 4px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.row { display: flex; gap: 12px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row .field { flex: 1; }
.mode-buttons { display: flex; gap: 12px; justify-content: center; margin: 14px 0 8px; }
/* Puddlehold chips (same look as the DE/EN buttons on puddlehold.com): parchment, ink rim, gold when active. */
.home-link, .lang-switch button {
  display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 10px; line-height: 1;
  background: #ead6a4; color: #5a4120; border: 3px solid #2b1a0e; border-radius: 10px; box-shadow: 0 3px 0 #2b1a0e;
  font-family: inherit; text-decoration: none; cursor: pointer; transition: transform .1s ease, filter .1s ease;
}
.home-link:hover, .lang-switch button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.home-link:active, .lang-switch button:active { transform: translateY(2px); box-shadow: 0 1px 0 #2b1a0e; }
.home-link { position: absolute; top: 14px; left: 16px; z-index: 3; }
.lang-switch { position: absolute; top: 14px; right: 16px; display: flex; gap: 6px; z-index: 3; }
.lang-switch button { min-width: 40px; }
.lang-switch button.active { background: #ffd43a; color: #2b1a0e; }

/* Collapsible text blocks in the menu (privacy). */
.howto { margin-top: 10px; font-size: 14px; }
.howto summary { cursor: pointer; color: var(--gold); user-select: none; }
.imprint-link a { color: var(--gold); }
.howto-text { white-space: pre-line; text-align: left; line-height: 1.35; max-height: 38vh; overflow-y: auto; margin-top: 6px; overflow-wrap: anywhere; }
/* Hero select: all heroes on one screen, details in a side panel (stacks below on narrow screens). */
.panel.hero-panel { display: flex; flex-direction: column; width: min(1180px, 96vw); max-height: 96vh; padding: 14px 18px; }
.panel.hero-panel h2 { margin: 0 0 8px; }
/* The card column takes its content width so the 128 px portraits are never squeezed (a squeezed
   canvas is resampled and loses its pixel grid). */
.hero-select { display: grid; grid-template-columns: max-content minmax(220px, 1fr); gap: 12px; min-height: 0; flex: 1; }
.hero-grid { display: grid; grid-template-columns: repeat(5, 148px); gap: 6px; align-content: start; }
.hero-card {
  position: relative; background: var(--parch-tex); color: var(--ink); border: 0;
  border: 2px solid var(--gold-dark); border-radius: 8px; padding: 6px 4px; cursor: pointer; text-align: center; transition: transform .1s;
  min-width: 0;
}
.hero-card:hover { transform: translateY(-3px); }
.hero-card.selected { border-color: var(--gold); box-shadow: 0 0 16px rgba(240,194,74,.5); }
.hero-card canvas {
  width: 128px; height: 128px; max-width: none; aspect-ratio: 1; border-radius: 6px; box-sizing: content-box;
  background: #2a1a10; border: 2px solid var(--gold-dark);
}
.hero-card h3 { margin: 4px 0 1px; font-size: 14px; line-height: 1.15; color: #3a220c; overflow-wrap: break-word; hyphens: auto; }
.hero-card .role { font-size: 12px; line-height: 1.2; font-style: italic; color: #5a4120; }
.hero-detail {
  background: var(--parch-tex); color: var(--ink); border: 2px solid var(--gold-dark); border-radius: 8px;
  padding: 10px 12px; overflow-y: auto; min-height: 0; text-align: left;
  contain: size; /* the grid sets its height, so changing text never resizes the panel */
}
.hero-detail h3 { margin: 0 0 2px; font-size: 18px; color: #3a220c; }
.hero-detail .role { font-size: 13px; font-style: italic; color: #5a4120; }
.hero-detail .attr { font-size: 12px; margin: 4px 0; }
.hero-detail .ab { font-size: 12.5px; margin-top: 6px; border-top: 1px solid rgba(90,60,20,.3); padding-top: 4px; }
.hero-detail .ab b { color: #7a2a10; }
.hero-panel .row.end { margin-top: 10px; }
@media (max-width: 760px) and (orientation: portrait) {
  .panel.hero-panel { padding: 10px 12px; height: 96vh; }
  .hero-select { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .hero-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .hero-card { padding: 4px 2px; }
  .hero-card canvas { width: clamp(38px, 6vh, 56px); }
  .hero-card h3 { font-size: clamp(8px, 2.2vw, 12px); }
  .hero-card .role { display: none; }
}
@media (max-height: 520px) {
  /* Start menu on a landscape phone: compact rows, and the screen scrolls if it still overflows. */
  .menu-panel { padding: 8px 18px 10px; width: min(520px, 94vw); }
  .logo { font-size: 30px; margin: 0; letter-spacing: 1px; }
  .sublogo { font-size: 15px; margin-bottom: 0; }
  .tagline { margin: 2px 0 6px; font-size: 13px; }
  .field { margin: 4px 0; gap: 2px; font-size: 13px; }
  .field input, .field select { font-size: 14px; padding: 4px 8px; }
  .btn.big { font-size: 15px; padding: 7px 16px; }
  .row.end { margin-top: 8px; }
  .menu-panel > .small { display: none; }
  .mode-buttons { margin: 8px 0 4px; }
  .sins-btn { margin: 4px 0; }
  .panel.hero-panel { padding: 8px 12px; max-height: 98vh; }
  .panel.hero-panel h2 { font-size: 18px; margin-bottom: 4px; }
  .hero-card { padding: 3px 2px; }
  .hero-card .role { display: none; }
  .hero-card h3 { font-size: clamp(9px, 1.4vw, 12px); margin-top: 2px; }
  .hero-panel .row.end { margin-top: 6px; }
  .hero-select { grid-template-columns: max-content minmax(170px, 1fr); }
  /* Landscape phone: smaller portraits so both rows fit above the buttons. */
  .hero-grid { grid-template-columns: repeat(5, 108px); gap: 4px; }
  .hero-card canvas { width: 64px !important; height: 64px !important; } /* sized inline by JS */
  .hero-detail { padding: 6px 8px; }
  .hero-detail h3 { font-size: 15px; }
  .hero-detail .ab { font-size: 11.5px; margin-top: 4px; }
}

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topbar {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; align-items: center;
  background: var(--wood-tex); border: 2px solid var(--gold-dark); border-top: 0; border-radius: 0 0 10px 10px; padding: 6px 18px; font-size: 14px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.tb-item { position: relative; }
.tb-item b { color: var(--gold); }
/* Fixed-width digits and value boxes, so the bar never changes width (and jumps) while the clock ticks. */
#topbar b, .gold b { font-variant-numeric: tabular-nums; }
#hud-wave, #hud-next { display: inline-block; min-width: 2ch; }
#hud-kills { display: inline-block; min-width: 4.5ch; }
.tb-item.clock { text-align: center; padding: 0 10px; border: 2px dashed var(--wood-light); border-radius: 8px; }
.tb-item.clock b { display: inline-block; min-width: 4.5ch; }
#hud-gold { display: inline-block; min-width: 4.5ch; }
.tb-item.castle { display: flex; align-items: center; gap: 6px; }
.tb-item.castle .bar { width: 170px; height: 16px; }
.tb-item.castle .bar span { line-height: 16px; font-size: 11px; }
.barracks { display: inline-flex; gap: 3px; vertical-align: middle; }
.barracks i {
  display: inline-block; width: 12px; height: 14px; border: 1px solid #120b05; background: linear-gradient(#c0402a, #6a1a0e);
  clip-path: polygon(0 0, 100% 0, 100% 65%, 50% 100%, 0 65%); box-shadow: inset 0 1px 0 rgba(255,255,255,.3);
}
.barracks i.down { background: #3a3632; opacity: .55; }

.bar { position: relative; height: 18px; background: #1a120a; border: 1px solid #000; border-radius: 4px; overflow: hidden; margin: 3px 0; }
.bar.thin { height: 6px; }
.bar .fill { height: 100%; width: 0; transition: width .15s; }
.bar span { position: absolute; inset: 0; z-index: 1; text-align: center; font-size: 12px; line-height: 18px; text-shadow: 0 1px 1px #000, 0 0 3px #000; font-weight: 700; }
.fill.hp { background: var(--hp); }
.fill.mp { background: var(--mp); }
.fill.xp { background: var(--xp); }
.bar.boss { height: 20px; width: 420px; }
.bar.boss .fill { background: #9a3ad0; }
.bar.boss span { line-height: 20px; font-size: 13px; }
.bar.thin span { display: none; }

#phase-banner {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%); color: var(--gold);
  background: rgba(60,20,10,.9); border: 1px solid var(--gold-dark); border-radius: 6px; padding: 4px 18px; font-size: 15px;
}
#bossbar { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); text-align: center; }
.boss-name { color: #f3c7ff; font-size: 17px; text-shadow: 0 2px 3px #000; }
#right-col { position: absolute; top: 54px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; }
#right-col > * { pointer-events: auto; }
#players {
  background: var(--wood-tex); border: 1px solid var(--gold-dark); border-radius: 6px; padding: 6px 9px; font-size: 12.5px; min-width: 190px;
}
#players:empty { display: none; }
#questlog {
  width: 330px; max-width: calc(100vw - 20px); max-height: calc(100vh - 250px); overflow: auto; font-size: 13px;
  background: var(--wood-tex); border: 2px solid var(--gold-dark); border-radius: 8px; padding: 8px 12px 10px; box-shadow: 0 4px 14px rgba(0,0,0,.55);
}
#questlog.hidden { display: none; }
#questlog .q-head { display: flex; align-items: center; justify-content: space-between; }
#questlog h3 { color: var(--gold); margin: 0 auto 0 0; font-size: 16px; }
#questlog .q-head .btn + .btn { margin-left: 4px; }
#questlog.fold .q-side, #questlog.fold .q .ds { display: none; }
#questlog h4 { color: var(--gold); margin: 9px 0 3px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: .85; }
#questlog .q { display: grid; grid-template-columns: 18px 1fr; gap: 0 6px; padding: 4px 6px; border-radius: 4px; margin: 2px 0; }
#questlog .q .mk { text-align: center; line-height: 18px; }
#questlog .q .tt { font-weight: 700; }
#questlog .q .tt em { font-style: normal; color: var(--gold); font-weight: 400; margin-left: 4px; }
#questlog .q .ds { grid-column: 2; color: var(--muted); font-size: 12px; line-height: 1.35; }
#questlog .q.now { background: rgba(240,194,74,.13); box-shadow: inset 3px 0 0 var(--gold); }
#questlog .q.now .tt::after { content: attr(data-now); margin-left: 6px; font-size: 10.5px; color: #1b1206; background: var(--gold); border-radius: 3px; padding: 0 4px; vertical-align: 1px; }
#questlog .q.done { opacity: .55; }
#questlog .q.done .tt { text-decoration: line-through; text-decoration-color: rgba(240,194,74,.6); }
#questlog .q.todo { opacity: .45; }
/* Short screens: the current quest's text keeps two lines (full text on hover), locked quests hide. */
@media (max-height: 700px) {
  #questlog h4 { margin: 5px 0 2px; }
  #questlog .q { padding: 2px 6px; }
  #questlog .q.now .ds { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #questlog .q.todo { display: none; }
}
@media (max-height: 520px) {
  #questlog .q.now .ds { display: none; }
}
#btn-quest.news { border-color: var(--gold); animation: questPulse 1.2s ease-in-out infinite; }
@keyframes questPulse { 50% { box-shadow: 0 0 10px 2px rgba(240,194,74,.85); } }
#players .pl { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
#players .sw { width: 10px; height: 12px; border: 1px solid #000; clip-path: polygon(0 0, 100% 0, 100% 65%, 50% 100%, 0 65%); }
#players .dead { opacity: .5; }
#feed { position: absolute; left: 10px; top: 120px; width: 380px; font-size: 14.5px; pointer-events: none; }
#feed div { background: rgba(28,18,8,.75); margin: 3px 0; padding: 3px 9px; border-radius: 3px; animation: fade 9s forwards; text-shadow: 0 1px 1px #000; }
#feed div.chat { border-left-color: #6cb3ff; animation: fadeChat 11s forwards; }
#feed div.err { border-left-color: #e2554a; color: #ffc1b8; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fadeChat { 0%, 91% { opacity: 1; } 100% { opacity: 0; } }
#respawn { position: absolute; top: 38%; left: 50%; transform: translateX(-50%); font-size: 26px; color: #ffd8c8; text-shadow: 0 2px 6px #000; pointer-events: none; }

#bottom {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: stretch;
  background: var(--wood-tex); border: 3px solid var(--gold-dark); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 10px 14px; width: min(1180px, 100vw);
  box-shadow: 0 -6px 22px rgba(0,0,0,.5);
}
.portrait-box {
  position: relative; width: 128px; height: 128px; flex: none; border-radius: 6px; align-self: center;
  background: #2a1a10; border: 2px solid var(--gold-dark);
}
.portrait-box canvas { width: 128px; height: 128px; display: block; border-radius: 4px; }
.portrait-box .lvl {
  position: absolute; bottom: -9px; right: -9px; color: var(--ink); font-weight: 600;
  width: 28px; height: 28px; text-align: center; line-height: 28px; font-size: 13px; z-index: 3;
  background: var(--gold); border-radius: 50%; border: 2px solid #000;
}
.vitals { width: 250px; align-self: center; }
.hero-name { font-size: 16px; margin-bottom: 2px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 8px; font-size: 12px; margin-top: 5px; text-shadow: 0 1px 1px #000; }
.stats span { display: flex; justify-content: space-between; align-items: baseline; padding: 1px 5px; background: rgba(0,0,0,.25); border-radius: 3px; }
.stats i { font-style: normal; font-size: 11px; color: var(--muted); }
.stats b { color: var(--parch); font-size: 13.5px; }
.stats .str i { color: #ff9a7a; } .stats .agi i { color: #9ae07a; } .stats .int i { color: #8ab8ff; }
.abilities, .inventory { display: grid; gap: 6px; align-content: center; padding: 6px; border-radius: 4px; background: rgba(0,0,0,.25); }
.abilities { grid-template-columns: repeat(2, 52px); }
.inventory { grid-template-columns: repeat(3, 38px); gap: 4px; }
.slot { position: relative; width: 58px; height: 58px; border-radius: 6px; background: #0d0804; border: 2px solid var(--gold-dark); cursor: pointer; overflow: hidden; }
.slot:hover { border-color: var(--gold); }
.abilities .slot { width: 52px; height: 52px; }
.inventory .slot { width: 38px; height: 38px; border-width: 1px; }
.slot.ult { border-color: #b061ff; box-shadow: 0 0 6px rgba(176,97,255,.45); }
.slot.armed { border-color: #fff2a0; box-shadow: 0 0 10px #f0c24a, inset 0 0 8px rgba(240,194,74,.6); }
.slot .charges { position: absolute; right: 1px; bottom: 0; z-index: 1; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 0 2px #000, 0 1px 1px #000; }
/* Pixel cursors (scripts/cursors.py): ink outline + bright fill reads on grass, mud, water and walls. */
canvas#game.enemy { cursor: url(../assets/ui/cursor_attack.png) 2 2, pointer; }
canvas#game.targeting { cursor: url(../assets/ui/cursor_aim.png) 14 14, crosshair; }
.tb-item.room { cursor: pointer; padding: 1px 8px; border: 1px dashed var(--gold-dark); border-radius: 4px; }
.tb-item.room b { letter-spacing: .5px; user-select: all; }
/* HerpDerp top bar icons shared with Lords (scripts/lords-sprites.py --tb there) */
.tbi { display: block; width: 18px; height: 18px; margin: auto; background: center / contain no-repeat; image-rendering: pixelated; pointer-events: none; }
.tbi-quest { background-image: url(../assets/ui/tb_quest.png); }
.tbi-lock { background-image: url(../assets/ui/tb_lock.png); }
.tbi-help { background-image: url(../assets/ui/tb_help.png); }
#btn-lock { font-size: 17px; }
#btn-lock.on { color: #1a1008; background: var(--gold); }
/* Drawn cursor while the mouse is locked to the game window (see mouselock.js). */
#vcursor {
  position: fixed; left: 0; top: 0; width: 32px; height: 32px; margin: -2px 0 0 -2px; z-index: 1000; pointer-events: none;
  background: no-repeat url(../assets/ui/cursor_move.png);
}
#vcursor.attack { background-image: url(../assets/ui/cursor_attack.png); }
#vcursor.aim { margin: -14px 0 0 -14px; background-image: url(../assets/ui/cursor_aim.png); }
#vcursor.hidden { display: none; }
.slot > canvas { width: 100%; height: 100%; display: block; }
/* Hotkey caps: gold, ink rim, 5x7 pixel glyphs at 2x (ui/keycap.js), same as in Lords. */
.slot .hk { position: absolute; left: 0; top: 0; z-index: 2; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 4px; background: var(--gold); border: 2px solid var(--ink); border-radius: 6px; box-shadow: 0 2px 0 rgba(0,0,0,.35); pointer-events: none; }
.slot .hk.sm { min-width: 18px; height: 18px; padding: 0 2px; border-radius: 5px; }
.slot .hk canvas { display: block; image-rendering: pixelated; }
/* Inventory caps only on filled slots; nine caps on empty slots were just noise. */
.inventory .slot.empty .hk { display: none; }
.slot .cd { position: absolute; inset: 0; z-index: 1; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; }
.slot.passive { border-color: #7a8fa8; }
.slot.nomana > canvas { filter: grayscale(.7) brightness(.6); }
.side { display: flex; flex-direction: column; gap: 6px; width: 172px; align-self: center; }
.gold { font-size: 19px; display: flex; align-items: center; gap: 7px; }
.gold b { color: var(--gold); }
.coin { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c4, #f0c24a 45%, #9a6a10); border: 1px solid #4a3000; }
#btn-shop { font-size: 15px; padding: 6px 8px; }
.tps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tps .btn { padding: 3px 2px; font-family: var(--serif); font-weight: 600; font-size: 13px; letter-spacing: 0; white-space: nowrap; }
.mini-frame { position: relative; margin-left: auto; align-self: center; flex: none; }
#minimap { display: block; width: 240px; height: 132px; border-radius: 4px; background: #0c1e28; cursor: pointer; border: 2px solid var(--gold-dark); }

/* Same size on every tab, so the tab buttons never move; a long tab scrolls inside the list. */
#shop { position: absolute; right: 16px; bottom: 178px; width: 690px; max-width: calc(100vw - 32px); height: min(560px, calc(100vh - 222px)); display: flex; flex-direction: column; overflow: hidden; }
#shop > .muted.small { flex: none; margin-top: 4px; }
.shop-head { display: flex; align-items: center; gap: 10px; }
.shop-head h3 { margin: 0; color: var(--gold); }
.tabs { display: flex; gap: 5px; flex: 1; flex-wrap: wrap; }
.shop-note { font-size: 12px; color: #ffb4a8; min-height: 16px; margin: 6px 0; }
.shop-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; flex: 1; min-height: 0; overflow-y: auto; align-content: start; }
.shop-item {
  display: flex; gap: 7px; align-items: center; background: var(--parch-tex); color: var(--ink); border-radius: 4px; padding: 3px 5px; cursor: pointer; border: 1px solid var(--gold-dark);
}
.shop-item:hover { border-color: var(--gold); filter: brightness(1.05); }
.shop-item.poor { opacity: .55; filter: grayscale(.4); }
.shop-item canvas { width: 36px; height: 36px; flex: none; border-radius: 3px; }
.shop-item .nm { font-size: 13px; color: #3a220c; font-weight: bold; }
.shop-item .ds { font-size: 11px; line-height: 1.15; color: #5a4120; }
.shop-item .pr { font-size: 12px; color: #7a4d00; font-weight: 700; }

#tooltip {
  position: fixed; max-width: 300px; background: var(--wood-tex); border: 1px solid var(--gold); border-radius: 6px;
  padding: 8px 11px; font-size: 13px; z-index: 50; pointer-events: none; box-shadow: 0 6px 16px rgba(0,0,0,.7);
}
#tooltip h4 { margin: 0 0 4px; color: var(--gold); font-size: 14px; border-bottom: 1px solid rgba(176,138,62,.4); padding-bottom: 3px; }
#chat { position: absolute; left: 10px; bottom: 182px; }
/* The history replaces the fading feed while the chat is open. */
body.chatting #feed { display: none; }
#chat-log {
  width: 380px; max-height: 210px; overflow-y: auto; margin-bottom: 4px; padding: 5px 8px; font-size: 14px; line-height: 1.35;
  background: rgba(28,18,8,.82); border: 1px solid var(--gold-dark); border-radius: 4px; text-shadow: 0 1px 1px #000;
}
#chat-log div { margin: 2px 0; overflow-wrap: anywhere; }
#chat input { width: 380px; font-family: var(--serif); font-size: 15px; padding: 6px 8px; background: var(--parch-tex); border: 2px solid var(--gold-dark); border-radius: 4px; outline: none; }
/* Shortcut overview (H): same layout as in Lords, two columns of sections with gold key caps. */
#help { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(1000px, 94vw); max-height: calc(100vh - 20px); text-align: center; }
#help h3 { color: var(--gold); margin: 0 0 8px; }
#help .sc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
#help .sc-col { display: flex; flex-direction: column; gap: 8px; }
#help .sc-sec { background: rgba(43,26,14,.55); border: 3px solid var(--ink); border-radius: 10px; padding: 6px 10px 8px; }
#help .sc-sec h4 { margin: 0 0 4px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
#help .sc-sec ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
#help .sc-sec li { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 8px; align-items: start; line-height: 1.15; font: var(--tiny); }
#help .sc-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
#help .sc-keys i { font-style: normal; color: var(--muted); padding: 0 1px; font: var(--tiny); }
#help kbd {
  font: var(--tiny); color: var(--ink); background: linear-gradient(#ffe27a, var(--gold)); border: 2px solid var(--ink); border-radius: 6px;
  padding: 0 5px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; box-shadow: 0 2px 0 rgba(0,0,0,.35); white-space: nowrap;
}
#help .sc-desc { color: var(--text); font: var(--tiny); }
#help .sc-goal { margin: 8px 0 0; color: var(--muted); font: var(--tiny); text-align: left; }
#help .btn { margin-top: 8px; }
#end .panel { text-align: center; min-width: 400px; }
#end h1 { color: var(--gold); font-size: 42px; margin: 0 0 8px; text-shadow: 0 3px 0 #6b4a10; }
#end-stats { margin: 12px 0 18px; font-size: 14px; }
#end-stats table { margin: 0 auto; border-collapse: collapse; }
#end-stats td, #end-stats th { padding: 3px 10px; }
#end-stats th { color: var(--gold); border-bottom: 1px solid rgba(176,138,62,.4); }
@media (max-width: 520px) {
  /* The result tables must not push the screen sideways on a phone. */
  #end .panel { min-width: 0; }
  #end-stats { font-size: 12px; }
  #end-stats td, #end-stats th { padding: 3px 4px; }
  #end-top { font-size: 12px; }
  #end-top td { padding: 0 4px; }
}
#end-record { margin: 0 0 10px; padding: 10px 12px; border: 2px solid var(--gold); border-radius: 8px; background: rgba(0,0,0,.25); }
#end-record-title { margin: 0 0 8px; color: var(--gold); font-family: var(--title); font-size: 20px; }
#end-record-form { display: flex; gap: 8px; justify-content: center; }
#inp-nick { width: 180px; font-family: var(--serif); font-size: 16px; padding: 6px 8px; background: var(--parch-tex); border: 2px solid var(--gold-dark); border-radius: 4px; outline: none; }
#inp-nick:focus { border-color: var(--gold); }
#end-record .fine { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
#end-record .fine.err { color: #e07a5f; }
#end-top { margin: 0 0 10px; font-size: 13px; }
#end-top h3 { margin: 0 0 4px; color: var(--gold); font-weight: 400; font-size: 20px; }
#end-top table { margin: 0 auto; border-collapse: collapse; }
#end-top td { padding: 0 8px; white-space: nowrap; }
#end-top td:nth-child(2) { color: var(--gold); }
#end-top td:nth-child(3) { text-align: right; }
#end-top tr.me td { background: rgba(176,138,62,.25); }

@media (max-width: 1100px) {
  .mini-frame { display: none; }
  .vitals { width: 170px; }
  /* Top bar: tighter, and it may wrap into a second row instead of running past the screen. */
  #topbar { width: max-content; max-width: 100vw; flex-wrap: wrap; justify-content: center; gap: 4px 8px; padding: 4px 8px; font-size: 13px; }
  .tb-item.castle .bar { width: 110px; }
  .tb-item.room span { display: none; }
  #questlog { width: 250px; font-size: 12px; max-height: calc(100vh - 275px); }
  /* Clear the wrapped top bar, and keep the boss bar left of the quest log. */
  #right-col { top: 72px; }
  /* Long hero names: the player list stays narrow and truncates instead of covering the boss bar. */
  #players { max-width: 240px; }
  #players .pl { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #players .sw { display: inline-block; vertical-align: middle; margin-right: 6px; }
  #bossbar { left: calc(50% - 20px); max-width: calc(100vw - 20px); }
  .boss-name { font-size: 15px; }
  .bar.boss { width: clamp(220px, 100vw - 560px, 420px); }
  #questlog .q .ds { font-size: 11px; }
  /* Stats grid: columns may shrink below their content so the grid never spills into the abilities. */
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 3px; font-size: 11px; }
  .stats span { padding: 1px 2px; overflow: hidden; }
  /* When a three-digit value needs the room, the label gives way, never the number. */
  .stats i { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stats b { flex: none; }
  .stats i { font-size: 10px; }
  .stats b { font-size: 12px; }
}
@media (max-width: 800px) {
  #bottom { gap: 8px; padding: 8px; }
  .side { width: 160px; }
  .tps .btn { font-size: 12px; padding: 3px 1px; }
}
@media (max-height: 760px) {
  /* Below the boss bar (84-142 px) so wave messages never cover it. */
  #feed { top: 150px; max-height: calc(100vh - 150px - 170px); overflow: hidden; }
}

/* Sünden-Katalog (mutators) in the main menu */
.sins-btn { width: 100%; margin: 6px 0; }
.sins-btn b { color: var(--gold); }
/* The catalog opens as its own centered window, so it never makes the menu scroll. */
.sins { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(5,10,14,.55); padding: 8px; }
.sins.hidden { display: none; }
.panel.sins-panel { width: min(640px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.sins-head { display: flex; align-items: center; gap: 10px; }
.sins-head h3 { margin: 0; color: var(--gold); flex: 1; }
.sins-total { font-size: 13px; color: var(--muted); }
.sins-total b { color: var(--gold); font-size: 16px; }
.sins-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sins-cat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sins-cat h4 { margin: 0 0 2px; color: var(--gold); font-size: 14px; }
.sin { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; text-align: left; padding: 5px 7px; font-size: 13px; line-height: 1.2; }
.sin .nm { font-weight: 700; min-width: 0; overflow-wrap: break-word; }
.sin .ab { font-size: 11px; white-space: nowrap; opacity: .85; }
.sin canvas { width: 22px; height: 22px; flex: none; align-self: center; image-rendering: pixelated; }
.sins-detail canvas { float: left; width: 40px; height: 40px; margin: 0 8px 2px 0; image-rendering: pixelated; }
.sins-detail { height: 4.6em; overflow-y: auto; contain: size; font-size: 13px; line-height: 1.3; padding: 6px 8px; border: 1px solid var(--gold-dark); border-radius: 6px; background: rgba(0,0,0,.18); }
.sins-detail .ab { color: var(--gold); }
.sins-foot { display: flex; align-items: center; gap: 10px; }
.sins-foot p { flex: 1; margin: 0; }
@media (max-height: 520px) {
  .panel.sins-panel { padding: 8px 12px; gap: 5px; }
  .sins-head h3 { font-size: 16px; }
  .sin { padding: 3px 6px; font-size: 12px; }
  .sins-detail { height: 3.9em; font-size: 12px; }
}
@media (max-width: 520px) {
  .sin { flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 5px; font-size: 12px; }
  .sins-head { flex-wrap: wrap; }
  /* Keep the top bar clear of the round menu button (top right, see vendor/puddlehold-hud). */
  html #hud #topbar { box-sizing: border-box; width: 100vw; padding-right: 52px; }
}

/* Relics: owned strip above the inventory, draft cards after a boss */
.inv-col { display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.relics { display: flex; gap: 3px; min-height: 0; padding: 0 6px; }
.relics canvas { width: 20px; height: 20px; image-rendering: pixelated; border: 1px solid var(--gold-dark); border-radius: 3px; }
.bless { align-self: flex-start; margin: 0 6px; padding: 0 6px; border: 1px solid var(--gold); border-radius: 3px; color: var(--gold); font-size: 11px; line-height: 16px; white-space: nowrap; animation: blessGlow 2s ease-in-out infinite; }
.bless[data-k=pack] { color: #9fd8ff; border-color: #9fd8ff; }
.bless[data-k=hunt] { color: #b8e08a; border-color: #b8e08a; }
@keyframes blessGlow { 50% { box-shadow: 0 0 6px 1px currentColor; } }
#draft { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 30; padding: 14px 18px; max-width: min(820px, 96vw); text-align: center; }
#draft h3 { margin: 0 0 4px; color: var(--gold); }
.draft-cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.relic-card { width: 165px; background: var(--parch-tex); color: var(--ink); border: 2px solid var(--gold-dark); border-radius: 6px; padding: 8px; cursor: pointer; text-align: left; font-family: var(--serif); }
.relic-card:hover { border-color: var(--gold); filter: brightness(1.06); }
.relic-card canvas { display: block; margin: 0 auto 6px; width: 48px; height: 48px; image-rendering: pixelated; }
.relic-card .nm { font-weight: 700; text-align: center; margin-bottom: 4px; }
.relic-card .up { color: #1f6d1a; font-size: 13px; }
.relic-card .down { color: #8a1c14; font-size: 13px; }


/* Large desktops: scale the whole HUD up in the same steps as Lords, so text and hotkeys keep
   their on-screen size. hud.js divides by this zoom where it positions from screen pixels. */
@media (min-width: 1800px) and (min-height: 980px) {
  #hud { zoom: 1.25; }
}
@media (min-width: 2300px) and (min-height: 1300px) {
  #hud { zoom: 1.5; }
}

/* Menu = the Puddlehold lobby (client/vendor/puddlehold-lobby, draft C, 04.11.2026). */
#menu { place-items: start center; }
.menu-wrap { position: relative; width: min(1040px, 100%); display: flex; flex-direction: column; gap: 8px; margin: auto 0; padding: 8px; }
.menu-wrap .error { text-align: center; }
.menu-legal { text-align: center; }
.menu-legal .howto.privacy, .menu-legal .howto.imprint-link { display: inline-block; margin: 0 10px; vertical-align: top; }
.menu-opts { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.menu-opt { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu-opt select { font: inherit; }
.menu-sins { flex: 1; }
.menu-sins b { color: var(--gold); margin-left: 4px; }
.menu-server { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
#menu-lobby.no-pw .phl-field:has(#phl-pw) { display: none; }

/* Minimap as in Schlammschlacht: its own frame in the bottom right corner, top-down map with the
   arenas in a column beside the main field (nearly square). The bottom bar moves left of it where the screen is too narrow. */
#mini-corner { position: absolute; right: 0; bottom: 0; margin: 0; padding: 6px; background: var(--wood-tex); border: 3px solid var(--gold-dark); border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; box-shadow: 0 -6px 22px rgba(0,0,0,.5); }
#mini-corner #minimap { width: 228px; height: 190px; }
#bottom { width: max-content; max-width: 100vw; left: calc(50% - 130px); }
/* The shop opens left of the corner frame, so it never covers the minimap. */
#shop { right: 276px; max-width: calc(100vw - 292px); }
@media (min-width: 1400px) {
  #mini-corner #minimap { width: 276px; height: 230px; }
  #bottom { left: calc(50% - 155px); }
  #shop { right: 324px; max-width: calc(100vw - 340px); }
}
@media (max-width: 1100px) {
  #bottom { left: 50%; }
}

/* Phone HUD (portrait and landscape): status bar top left, system buttons top right (menu, chat,
   see vendor/puddlehold-hud), quest/help buttons below them, hero panel as a compact grid at the
   bottom, feed and minimap directly above it. --hud-bottom is the bar height (hud.js).
   `html #hud` out-ranks the skins' `html.style-*` rules. */
@media (max-width: 760px), (max-height: 520px) {
  html #hud #topbar {
    left: 0; transform: none; box-sizing: border-box; max-width: none; width: calc(100vw - 106px - env(safe-area-inset-right, 0px));
    display: grid; grid-template-columns: repeat(4, max-content); justify-content: start; align-items: center; gap: 2px 7px;
    padding: 4px 8px 5px calc(8px + env(safe-area-inset-left, 0px)); font-size: 12px; border-radius: 0 0 14px 0; box-shadow: 0 3px 8px rgba(0,0,0,.45);
  }
  html #hud #topbar::before, html #hud #topbar::after { display: none; }
  html #hud #topbar .tb-item { order: 1; min-width: 0; padding: 0; }
  html #hud #topbar .tb-item.castle { order: 5; grid-column: span 2; gap: 4px; }
  html #hud #topbar .tb-item.castle > span { display: none; }
  html #hud #topbar .tb-item.castle .bar { flex: 1; width: auto; min-width: 100px; height: 16px; margin: 0; }
  html #hud #topbar .tb-item:has(.barracks) { order: 6; }
  html #hud #topbar .tb-item.clock { order: 4; border: 0; padding: 0; }
  html #hud #topbar .tb-item.room { order: 7; padding: 0 5px; max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
  html #hud #topbar .tb-item.room[title=""] { display: none; } /* solo: nothing to share */
  html #hud #topbar .tb-item:has(.barracks) > span:first-child { display: none; }
  html #hud-ablass-box { order: 8 !important; }
  html #hud #topbar #hud-kills { min-width: 3ch; }
  html #hud #topbar .tb-item.clock b { min-width: 4ch; }
  html #hud #topbar .barracks i { width: 11px; height: 13px; }
  html #hud #topbar .btn.tiny { position: fixed; right: calc(10px + env(safe-area-inset-right, 0px)); width: 40px; height: 40px; }
  html #hud #btn-quest { top: 58px; }
  html #hud #btn-help { top: 104px; }
  html #hud #btn-lock { display: none; } /* mouse lock is a desktop function */
  html #hud #phase-banner { top: 58px; font-size: 13px; padding: 3px 12px; max-width: calc(100vw - 130px); text-align: center; }
  html #hud #bossbar { top: 90px; left: 50%; max-width: calc(100vw - 130px); }
  html #hud .bar.boss { width: min(300px, calc(100vw - 130px)); }
  html #hud .boss-name { font-size: 13px; }
  /* Players list only with company; quest log opens left of the button column. */
  html #hud #right-col { display: contents; }
  html #hud #players { position: absolute; top: 58px; left: calc(8px + env(safe-area-inset-left, 0px)); min-width: 0; max-width: min(220px, 52vw); max-height: 6.2em; overflow: hidden; padding: 3px 7px; font-size: 11px; }
  html #hud #players:not(:has(.pl + .pl)) { display: none; }
  html #hud #questlog { position: absolute; top: 58px; right: calc(58px + env(safe-area-inset-right, 0px)); width: min(300px, calc(100vw - 70px)); }
  /* Feed: the last two lines, one row each, above the bar and left of the minimap. */
  html #hud #feed { left: calc(8px + env(safe-area-inset-left, 0px)); top: auto; bottom: calc(var(--hud-bottom, 200px) + 6px); width: min(360px, calc(100vw - 150px)); max-height: none; font-size: 14px; overflow: visible; }
  html #hud #feed div { margin: 2px 0; padding: 2px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html #hud #feed div:not(:nth-last-child(-n+2)) { display: none; }
  html #hud #chat { left: calc(8px + env(safe-area-inset-left, 0px)); bottom: calc(var(--hud-bottom, 200px) + 6px); max-width: calc(100vw - 150px); }
  html #hud #respawn { font-size: 20px; }
  html #hud #mini-corner { display: block; right: 0; bottom: var(--hud-bottom, 200px); padding: 3px; border-width: 2px 0 0 2px; border-radius: 8px 0 0 0; }
  html #hud #mini-corner #minimap { width: 104px; height: 87px; }

  html #hud #bottom {
    left: 0; transform: none; width: 100%; max-width: 100vw; box-sizing: border-box; gap: 4px 6px; align-items: center;
    display: grid; grid-template-columns: 58px minmax(0, 1fr) 128px; grid-template-areas: "por vit gld" "por vit shp" "abl abl tps" "inv inv inv";
    padding: 6px calc(8px + env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
    border-width: 3px 0 0; border-radius: 12px 12px 0 0;
  }
  html #hud #bottom .portrait-box { grid-area: por; width: 58px; height: 58px; align-self: center; }
  html #hud #bottom .portrait-box canvas { width: 100%; height: 100%; }
  html #hud #bottom .portrait-box .lvl { width: 22px; height: 22px; line-height: 22px; font-size: 11px; bottom: -6px; right: -6px; border-width: 2px; }
  html #hud #bottom .vitals { grid-area: vit; width: auto; min-width: 0; }
  html #hud #bottom .hero-name { font-size: 13px; margin: 0; }
  html #hud #bottom .bar { height: 15px; margin: 2px 0; }
  html #hud #bottom .bar span { font-size: 11px; line-height: 14px; }
  html #hud #bottom .bar.thin { height: 5px; }
  html #hud #bottom .stats { display: none; }
  html #hud #bottom .abilities { grid-area: abl; grid-template-columns: repeat(4, 48px); gap: 5px; padding: 3px 5px; justify-self: start; }
  html #hud #bottom .abilities .slot { width: 48px; height: 48px; }
  html #hud #bottom .inv-col { grid-area: inv; min-width: 0; }
  html #hud #bottom .inventory { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; padding: 3px; }
  html #hud #bottom .inventory .slot { width: auto; height: auto; aspect-ratio: 1; }
  html #hud #bottom .side { display: contents; }
  html #hud #bottom .gold { grid-area: gld; font-size: 16px; justify-self: end; gap: 5px; }
  html #hud #bottom #btn-shop { grid-area: shp; min-height: 36px; font-size: 14px; padding: 4px 6px; }
  html #hud #bottom .tps { grid-area: tps; gap: 4px; }
  html #hud #bottom .tps .btn { min-height: 36px; font-size: 11px; padding: 2px 1px; overflow: hidden; text-overflow: ellipsis; }

  html #hud #shop { left: 6px; right: 6px; top: 58px; bottom: calc(var(--hud-bottom, 200px) + 6px); width: auto; max-width: none; height: auto; padding: 8px 10px; }
  html #hud #shop .shop-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html #hud #shop > .muted.small { display: none; }
  /* An open quest log takes the place of minimap and feed. */
  html #hud:has(#questlog:not(.hidden)) :is(#mini-corner, #feed) { display: none; }
  html #hud #shop-close, html #hud .shop-head .btn.tiny { min-width: 36px; min-height: 36px; }
  html #hud .shop-note { margin: 3px 0; }
}
@media (pointer: coarse) and (max-width: 760px), (pointer: coarse) and (max-height: 520px) {
  html #hud .slot .hk, html #hud .tp-key { display: none; } /* no keyboard: caps and key hints only take room */
}
/* Landscape phone: one status row, hero panel as a wide two-row grid. */
@media (max-height: 520px) and (orientation: landscape) {
  html #hud #topbar { display: flex; flex-wrap: nowrap; gap: 4px 12px; padding-top: 3px; padding-bottom: 4px; }
  html #hud #topbar .tb-item.castle { flex: 0 0 150px; }
  html #hud #btn-quest { top: 54px; }
  html #hud #btn-help { top: 98px; }
  html #hud #phase-banner { top: 44px; }
  html #hud #bossbar { top: 74px; }
  html #hud #players, html #hud #questlog { top: 44px; }
  html #hud #bottom {
    grid-template-columns: 60px minmax(110px, 150px) max-content max-content minmax(0, 1fr);
    grid-template-areas: "por vit abl gld shp" "por vit inv tps tps";
  }
  html #hud #bottom .portrait-box { width: 60px; height: 60px; }
  html #hud #bottom .abilities { grid-template-columns: repeat(4, 44px); }
  html #hud #bottom .abilities .slot { width: 44px; height: 44px; }
  html #hud #bottom .inventory { grid-template-columns: repeat(9, 36px); }
  html #hud #bottom .inventory .slot { width: 36px; height: 36px; aspect-ratio: auto; }
  html #hud #bottom .tps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html #hud #bottom .tps .btn { font-size: 10px; letter-spacing: -.2px; }
  html #hud #shop { top: 54px; }
  html #hud #shop .shop-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  html #hud #topbar { font-size: 11px; column-gap: 5px; }
}

/* Controls sheet on a phone: one column, scrolls inside the screen, and stays above the HUD bars
   (their z-indexed parts showed through it). */
@media (max-width: 760px), (max-height: 520px) {
  html #hud #help { z-index: 40; width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; padding: 8px 10px; }
  html #hud #help .sc-grid { grid-template-columns: 1fr; gap: 8px; }
  html #hud #help .sc-sec li { grid-template-columns: minmax(0, auto) minmax(0, 1fr); }
}
@media (max-width: 520px) {
  html #hud #help .sc-sec li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-height: 520px) and (min-width: 600px) {
  html #hud #help .sc-grid { grid-template-columns: 1fr 1fr; }
}

/* Party heroes (Papst, Barde) are marked in the hero pick. */
.hero-card { position: relative; }
.party-mark { position: absolute; top: 6px; right: 6px; padding: 1px 6px; border-radius: 8px; font-size: 11px; background: rgba(30, 18, 8, .85); color: #ffd43a; border: 1px solid #2b1a0e; }
.party-tag { margin: 4px 0; color: #ffd43a; font-size: 13px; }
.menu-pc { text-align: center; margin: 4px 0 0; }

/* Store on touch: quantity buttons and sell mode instead of Shift, Ctrl and right click. */
.shop-touch { display: none; gap: 6px; margin: 4px 0; flex-wrap: wrap; }
.shop-touch .btn.active { outline: 2px solid #ffd43a; }
.shop-touch .sell { margin-left: auto; }
#hud-inv.selling .slot { outline: 2px dashed #ff8a7a; }
@media (pointer: coarse) {
  .shop-touch { display: flex; }
  .shop-touch .btn { min-width: 44px; min-height: 40px; }
  .menu-opt select { min-height: 40px; }
}
/* The controls sheet keeps a close button in reach while it scrolls. */
#help .help-x { position: sticky; top: 0; float: right; z-index: 1; min-width: 40px; min-height: 40px; }

@media (max-width: 760px), (max-height: 520px) {
  /* Two short lines per message instead of one cut with "…". */
  html #hud #feed div { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  /* Touch targets of at least 40 px. */
  html #hud #bottom #btn-shop, html #hud #bottom .tps .btn { min-height: 40px; }
}
/* Narrow portrait phones: the inventory takes two rows so every slot stays 40 px or more. */
@media (max-width: 430px) and (orientation: portrait) {
  html #hud #bottom .inventory { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html #hud #bottom .inventory .slot { aspect-ratio: auto; height: 42px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  html #hud #bottom .inventory { grid-template-columns: repeat(9, 40px); }
  html #hud #bottom .inventory .slot { width: 40px; height: 40px; }
}
/* Hero pick in portrait: all ten heroes in two rows of five, so none hides below the fold. */
@media (max-width: 760px) and (orientation: portrait) {
  html.style-herpderp .hero-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  html.style-herpderp .hero-card { padding: 3px 2px; }
  html.style-herpderp .hero-card h3 { font-size: 10px !important; -webkit-line-clamp: 2; margin: 2px 0 0; }
  html.style-herpderp .hero-card .role { display: none; }
  html.style-herpderp .party-mark { top: 2px; right: 2px; font-size: 9px; padding: 0 3px; }
  html.style-herpderp .hero-select { grid-template-rows: max-content minmax(0, 1fr); }
}

/* Imprint, privacy policy and chat rules stay on screen at the bottom of the menu (11.11.2026);
   the texts live once on puddlehold.com instead of a copy per game. */
.menu-legal-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px;
  padding: 0 12px env(safe-area-inset-bottom); background: rgba(30, 18, 8, .86); border-top: 2px solid #2b1a0e; }
.menu-legal-bar a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 6px; color: #ffd43a; text-decoration: underline; text-shadow: 1px 1px 0 #2b1a0e; }
#menu { padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
