:root {
  --bg: #120904;
  --wood: #2b1a10;
  --wood2: #3a2416;
  --wood3: #4d311e;
  --line: #0a0503;
  --beer: #f5a623;
  --beer-d: #cf7f12;
  --foam: #fff6d5;
  --orange: #ff7a00;
  --pink: #ff5fae;
  --delft: #2a5bb0;
  --green: #2ecc71;
  --red: #e8384f;
  --text: #f6ead2;
  --muted: #b89c7a;
  --px: 'Press Start 2P', monospace;
  --vt: 'VT323', monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--vt); font-size: 20px; line-height: 1.15; overscroll-behavior: none; }
body { background: radial-gradient(ellipse at top, #2a150a 0%, var(--bg) 60%) fixed; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--px); font-weight: normal; letter-spacing: 1px; }
h3 { font-size: 11px; color: var(--beer); margin: 14px 0 8px; }
.hint { color: var(--muted); font-size: 17px; margin: 4px 0 10px; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: 100dvh; max-width: 1400px; margin: 0 auto; }

/* ---------------- HUD */
#hud { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 12px; background: var(--wood); border-bottom: 4px solid var(--line); box-shadow: inset 0 -4px 0 var(--wood2); }
.pr-block { min-width: 0; }
#promille { font-family: var(--px); font-size: clamp(18px, 5vw, 30px); color: var(--beer); text-shadow: 3px 3px 0 #5a2d00; white-space: nowrap; }
#tier { font-family: var(--px); font-size: 10px; color: var(--pink); margin-top: 6px; }
.hud-stats { display: flex; gap: 14px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat .lbl { font-size: 14px; color: var(--muted); }
.stat b { font-family: var(--px); font-size: 12px; font-weight: normal; margin-top: 3px; }
#boosts { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
#boosts:empty { display: none; }
.boost { font-size: 16px; padding: 1px 6px; background: #532c0b; border: 2px solid var(--beer); color: var(--foam); white-space: nowrap; }
.boost.click { border-color: var(--pink); background: #4a1330; }
.boost.hh { border-color: #7cf; background: #13324a; animation: pulse 1s infinite; }

/* ---------------- stage */
#left { display: flex; flex-direction: column; min-height: 0; }
#stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; container-type: inline-size; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; border-bottom: 4px solid var(--line); }
#scene { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; cursor: pointer; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
.plate { position: absolute; transform: translate(-50%, -100%); text-align: center; font-size: clamp(9px, 2.7cqw, 20px); line-height: 1; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; white-space: nowrap; max-width: 9cqw; }
.plate { max-width: 15cqw; }
.plate .n { overflow: hidden; text-overflow: ellipsis; display: block; }
.plate .p { color: var(--beer); font-size: .85em; }
.plate.me { max-width: 30cqw; font-size: clamp(13px, 3.4cqw, 26px); }
.bubble { position: absolute; transform: translate(-50%, -100%); background: var(--foam); color: #2b1a10; font-size: clamp(11px, 2.6cqw, 20px); padding: 2px 6px; border: 2px solid #000; max-width: 34cqw; white-space: normal; text-align: center; animation: pop .15s ease-out; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 6px; height: 6px; background: var(--foam); border-right: 2px solid #000; border-bottom: 2px solid #000; transform: translateX(-50%) rotate(45deg); }
.floater { position: absolute; transform: translate(-50%, -50%); font-family: var(--px); font-size: clamp(8px, 2cqw, 14px); color: var(--foam); text-shadow: 2px 2px 0 #7a3b00; animation: floatUp .9s ease-out forwards; pointer-events: none; }
.floater.hik { color: var(--pink); font-family: var(--vt); font-size: clamp(14px, 3.5cqw, 26px); }
.bigword { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--px); font-size: clamp(18px, 7cqw, 56px); color: var(--beer); text-shadow: 4px 4px 0 #5a2d00, -2px -2px 0 #000; animation: bigword 1.6s ease-out forwards; white-space: nowrap; pointer-events: none; }
#hh-banner { position: absolute; top: 4px; right: 4px; font-family: var(--px); font-size: clamp(7px, 1.8cqw, 12px); background: rgba(0,0,0,.6); border: 2px solid #7cf; padding: 4px 6px; color: #bff; }
#hh-banner.on { border-color: var(--pink); color: #fff; animation: pulse .8s infinite; }
#pub-name { position: absolute; top: 4px; left: 4px; font-family: var(--px); font-size: clamp(7px, 1.7cqw, 11px); background: rgba(0,0,0,.55); padding: 4px 6px; color: var(--foam); }
#conn { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: var(--red); padding: 4px 10px; font-family: var(--px); font-size: 10px; }

/* ---------------- buttons */
.btn { font-family: var(--px); font-size: 12px; padding: 10px 12px; background: var(--wood3); border: none; color: var(--foam); box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.12), 0 0 0 3px var(--line); transition: transform .05s; touch-action: manipulation; }
.btn:active { transform: translateY(2px); box-shadow: inset 4px 4px 0 rgba(0,0,0,.35), 0 0 0 3px var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn small { display: block; font-family: var(--vt); font-size: 16px; margin-top: 4px; color: var(--foam); opacity: .85; }
.btn.small { font-size: 10px; padding: 8px 10px; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 16px; }
#actions { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; padding: 10px 12px 12px; background: var(--wood); }
#btn-slok { background: var(--beer-d); color: #fff; font-size: 18px; }
#btn-proost { background: #6b1f4a; }
#btn-proost.open { background: var(--pink); color: #2b0015; animation: pulse .5s infinite; }
#btn-rondje { background: #1f4e79; }

/* ---------------- panel */
#panel { display: flex; flex-direction: column; background: var(--wood); min-height: 0; border-top: 4px solid var(--line); }
#tabs { display: flex; overflow-x: auto; scrollbar-width: none; background: var(--wood2); border-bottom: 4px solid var(--line); flex-shrink: 0; }
#tabs button { position: relative; flex: 1 0 auto; background: none; border: none; padding: 10px 10px; font-family: var(--px); font-size: 9px; color: var(--muted); border-right: 2px solid var(--line); }
#tabs button.on { color: var(--foam); background: var(--wood); box-shadow: inset 0 -3px 0 var(--beer); }
.dot { position: absolute; top: 5px; right: 4px; width: 7px; height: 7px; background: var(--pink); }
.tab { display: none; padding: 10px 12px calc(20px + var(--safe-b)); overflow-y: auto; flex: 1; min-height: 0; }
.tab.on { display: block; }

.qty { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); }
.qty button { background: var(--wood2); border: 2px solid var(--line); padding: 3px 8px; font-size: 18px; }
.qty button.on { background: var(--beer-d); color: #fff; }

.item { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px; margin-bottom: 6px; background: var(--wood2); border: 3px solid var(--line); box-shadow: inset 3px 3px 0 rgba(255,255,255,.05); cursor: pointer; width: 100%; text-align: left; }
.item img { width: 40px; height: 40px; image-rendering: pixelated; }
.item .nm { font-family: var(--px); font-size: 10px; color: var(--foam); }
.item .ds { font-size: 16px; color: var(--muted); margin-top: 3px; }
.item .cost { font-family: var(--px); font-size: 10px; color: var(--beer); text-align: right; }
.item .own { font-family: var(--px); font-size: 16px; color: #ffffff30; text-align: right; }
.item.cant { opacity: .5; }
.item.cant .cost { color: var(--red); }
.item.locked { filter: brightness(.35) grayscale(1); cursor: default; }
.item:not(.cant):not(.locked):hover { border-color: var(--beer-d); }

.owned-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.owned-grid img { width: 32px; height: 32px; image-rendering: pixelated; background: var(--wood2); border: 2px solid var(--line); padding: 2px; }

.card { background: var(--wood2); border: 3px solid var(--line); padding: 10px; margin-bottom: 10px; }
.card h3 { margin-top: 0; }
.card p { margin: 6px 0; font-size: 18px; }
.help p { font-size: 17px; color: #e0cfb0; }
.row { display: flex; gap: 8px; margin: 6px 0; }
.row.center { justify-content: center; }
.row input, #chat-form input, .box input { flex: 1; min-width: 0; background: #1a0f08; border: 3px solid var(--line); padding: 8px; font-size: 20px; color: var(--foam); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips button { background: #1a0f08; border: 2px solid var(--wood3); padding: 3px 8px; font-size: 17px; color: var(--foam); }
.chips button b { color: var(--beer); font-weight: normal; }

.person { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; background: var(--wood2); border: 2px solid var(--line); margin-bottom: 4px; }
.person .sw { width: 14px; height: 14px; border: 2px solid #000; }
.person .pn { font-size: 19px; }
.person .pp { font-size: 16px; color: var(--beer); }
.person .btn { font-size: 9px; padding: 6px 8px; }

#chat-log { height: calc(100% - 110px); min-height: 200px; overflow-y: auto; background: #1a0f08; border: 3px solid var(--line); padding: 6px 8px; }
#tab-chat.on { display: flex; flex-direction: column; }
#chat-log { flex: 1; }
.cl { margin: 2px 0; font-size: 19px; word-wrap: break-word; }
.cl b { font-weight: normal; }
.cl.sys { color: var(--muted); font-style: italic; font-size: 17px; }
#chat-form { display: flex; gap: 8px; margin-top: 8px; }
.quick button { font-size: 16px; }

#lb { list-style: none; padding: 0; margin: 0; counter-reset: r; }
#lb li { display: grid; grid-template-columns: 34px 14px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; background: var(--wood2); border: 2px solid var(--line); margin-bottom: 4px; }
#lb li.me { border-color: var(--beer); }
#lb .rk { font-family: var(--px); font-size: 10px; color: var(--muted); }
#lb li:nth-child(1) .rk { color: #ffd23f; } #lb li:nth-child(2) .rk { color: #dfe6ee; } #lb li:nth-child(3) .rk { color: #d08a4a; }
#lb .sw { width: 12px; height: 12px; border: 2px solid #000; }
#lb .on-dot { color: var(--green); font-size: 14px; }
#lb .val { font-family: var(--px); font-size: 10px; color: var(--beer); }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ach { display: flex; gap: 8px; align-items: center; padding: 6px; background: var(--wood2); border: 2px solid var(--line); }
.ach img { width: 28px; height: 28px; image-rendering: pixelated; }
.ach .an { font-size: 17px; }
.ach .ad { font-size: 14px; color: var(--muted); }
.ach.off { opacity: .45; }
.prestige { border-color: #6b4fbf; background: #221736; }
.prestige h3 { color: #c9b5ff; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.swatches button { width: 30px; height: 30px; border: 3px solid #000; padding: 0; }
.swatches button.on { outline: 3px solid var(--foam); outline-offset: 1px; }

.toggle, .slider { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 19px; }
.slider input { flex: 1; accent-color: var(--beer); }
.toggle input { width: 20px; height: 20px; accent-color: var(--beer); }
code { display: block; background: #1a0f08; border: 2px dashed var(--wood3); padding: 6px; font-family: var(--vt); font-size: 16px; word-break: break-all; user-select: all; }
.footnote { color: var(--muted); font-size: 15px; text-align: center; margin-top: 14px; }

/* ---------------- modals */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8,4,2,.82); z-index: 50; padding: 16px; }
.box { width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; background: var(--wood); border: 4px solid var(--line); box-shadow: inset 4px 4px 0 var(--wood3), inset -4px -4px 0 #1a0f08, 8px 8px 0 #000; padding: 18px; }
.box label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 4px; color: var(--muted); }
.box h2 { font-size: 14px; color: var(--beer); margin: 0 0 10px; line-height: 1.4; }
.box p { font-size: 19px; }
#j-pfp { display: block; width: 120px; height: 120px; margin: 0 auto 6px; image-rendering: pixelated; filter: drop-shadow(4px 4px 0 #000); }
.logo { text-align: center; font-size: clamp(24px, 8vw, 36px); line-height: 1.25; color: var(--beer); text-shadow: 4px 4px 0 #5a2d00, -2px -2px 0 #000; margin: 4px 0 8px; }
.tag { text-align: center; color: var(--pink); margin-top: 0; }
#j-go { width: 100%; margin-top: 14px; background: var(--beer-d); }
.adtje { text-align: center; }
.adtje h2 { font-size: 22px; }
.vs { display: flex; justify-content: center; align-items: center; gap: 14px; font-size: 24px; }
.vs em { font-family: var(--px); font-size: 12px; color: var(--pink); font-style: normal; }
.scores { display: flex; justify-content: center; gap: 60px; font-family: var(--px); font-size: 24px; color: var(--beer); margin: 10px 0; }
.scores b { font-weight: normal; }
.count { font-family: var(--px); font-size: 36px; color: var(--foam); min-height: 44px; }
.mash { width: 100%; height: 120px; font-size: 28px; background: var(--red); margin-top: 8px; }
.result { font-size: 22px; color: var(--beer); min-height: 26px; }

#toasts { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: #1a0f08; border: 3px solid var(--beer); padding: 6px 12px; font-size: 19px; box-shadow: 4px 4px 0 #000; animation: pop .15s ease-out; text-align: center; }
.toast.warn { border-color: var(--red); }
.toast.ach { border-color: #ffd23f; background: #3a2a00; }
.toast.good { border-color: var(--green); }

@keyframes floatUp { 0% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: -40px; } }
@keyframes pop { 0% { transform: translate(-50%, -100%) scale(.6); } 100% { transform: translate(-50%, -100%) scale(1); } }
.toast { animation: none; }
@keyframes pulse { 50% { filter: brightness(1.35); } }
@keyframes bigword { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(3deg); } 30% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }

#feed { display: none; }
/* ---------------- desktop layout */
@media (min-width: 960px) {
  #app { grid-template-columns: 1fr 400px; grid-template-rows: auto 1fr; }
  #hud { grid-column: 1 / 3; flex-wrap: nowrap; min-height: 76px; }
  #boosts { width: auto; flex: 1; order: 2; justify-content: center; }
  #boosts:empty { display: flex; }
  .hud-stats { order: 3; margin-left: 0; }
  #left { grid-column: 1; overflow-y: auto; padding: 12px; background: var(--bg); }
  #stage { border: 4px solid var(--line); box-shadow: 8px 8px 0 #000; }
  #actions { margin-top: 12px; border: 4px solid var(--line); }
  #feed { display: block; margin-top: 12px; padding: 8px 12px; background: #1a0f08; border: 4px solid var(--line); min-height: 60px; }
  #feed:empty::before { content: 'Het is nog stil in de kroeg…'; color: var(--muted); }
  #panel { grid-column: 2; grid-row: 2; border-top: none; border-left: 4px solid var(--line); }
}
@media (max-width: 959px) {
  #app { height: 100dvh; }
  #panel { min-height: 0; overflow: hidden; }
  .hud-stats { gap: 10px; }
  .stat b { font-size: 10px; }
  #hud { padding: 6px 10px; }
  #actions { padding: 8px 10px; gap: 8px; }
  .btn small { font-size: 14px; }
}
@media (max-width: 420px) {
  .btn { font-size: 10px; padding: 9px 6px; }
  #btn-slok { font-size: 14px; }
  .stat .lbl { font-size: 12px; }
}
