/* Skellies table: black ink, bone white and Skellies yellow. */
:root {
  --ink: #141312;
  --paper: #fbf8ef;
  --panel: #23211f;
  --line: #3b3834;
  --muted: #bdb8ad;
  --muted-dark: #5e594f;
  --accent: #f5e02a;
  --danger: #c4231b;
  --ok: #2e7d32;
  --foe: #ff6b6b;
  --calm: #8ecae6;
  --ally: #95d5b2;
  --bone: #efe7d2;
  --bone-line: #cfc4a8;
  --water: #2f5763;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--paper); font-family: 'Alegreya Sans', system-ui, sans-serif; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
.display, .logo { font-family: 'Jolly Lodger', 'Bowlby One', sans-serif; line-height: 1; letter-spacing: 0.02em; font-weight: 400; }
.logo { font-size: 26px; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.label { font-size: 12px; font-weight: 800; color: var(--muted-dark); letter-spacing: 0.04em; }
.dark .label { color: var(--muted); }
.lede { margin: 0 0 12px; font-size: 15px; line-height: 1.45; }
.quote { font-family: 'Grenze Gotisch', serif; font-size: 18px; margin: 6px 0; }
.big-num { font-family: 'Bowlby One', sans-serif; font-size: 34px; line-height: 1.1; }

/* Buttons */
.btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--ink); background: transparent; color: var(--ink); font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.accent { background: var(--accent); border-color: var(--ink); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.btn.big { min-height: 52px; font-size: 15px; }
.btn.full { width: 100%; }
.btn.light { border-color: var(--paper); color: var(--paper); }
.btn.light.accent { border-color: var(--accent); color: var(--ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.dashed { border-style: dashed; }
.btn.on { background: var(--ink); color: var(--paper); }
.filebtn { margin-top: 8px; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 22px; border: 2px solid currentColor; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; padding: 0; }

.card { border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; }
.card.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grid6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.chip { display: inline-block; padding: 7px 12px; border-radius: 20px; background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 700; }
.badge { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; }
input[type=text], input[type=number], select, textarea { min-height: 44px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; color: var(--ink); padding: 0 10px; font-size: 16px; width: 100%; }
textarea { padding: 10px; min-height: 70px; resize: vertical; }
.dark input[type=text], .dark input[type=number], .dark select, .dark textarea { background: var(--ink); color: var(--paper); border-color: #4a463f; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 800; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* Map: castle rooms in bone and stone, flooded pipes in murky teal, fog everywhere else */
.map { position: relative; width: 100%; aspect-ratio: 390 / 520; }
.pipes { position: absolute; inset: 0; border-radius: 12px; background:
  radial-gradient(ellipse at 50% 100%, rgba(47, 87, 99, .45), transparent 60%),
  repeating-linear-gradient(0deg, #1b1a18 0 12px, #1f1d1b 12px 13px), #1b1a18; }
.room { position: absolute; border: 3px solid var(--ink); border-radius: 6px; background-color: var(--bone); padding: 5px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; color: var(--ink); overflow: hidden;
  background-image: linear-gradient(var(--bone-line) 1px, transparent 1px), linear-gradient(90deg, var(--bone-line) 1px, transparent 1px); background-size: 14px 14px; box-shadow: 3px 3px 0 #000; }
.room.water { background-color: #8fb8bf; background-image: repeating-radial-gradient(circle at 30% 120%, transparent 0 10px, rgba(255, 255, 255, .22) 10px 12px); }
.room.fog { background: repeating-linear-gradient(45deg, #2a2724 0 6px, #22201d 6px 12px); border-color: #000; box-shadow: none; }
.room.hidden { background-color: #4a4538; background-image: repeating-linear-gradient(45deg, #3a352c 0, #3a352c 6px, transparent 6px, transparent 12px); }
.room.here { box-shadow: 0 0 0 3px var(--paper), 3px 3px 0 #000; } .room.pend { box-shadow: 0 0 0 3px var(--accent); }
.room-name { padding: 2px 6px; border-radius: 4px; background: var(--ink); color: var(--paper); font-family: 'Jolly Lodger', sans-serif; font-size: 15px; line-height: 1.05; letter-spacing: .03em; max-width: 100%; }
.tokens { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.tok { width: 28px; height: 28px; border-radius: 14px; border: 2.5px solid var(--ink); color: var(--ink); font-weight: 800; font-size: 10px; display: flex; align-items: center; justify-content: center; flex: none; overflow: hidden; }
.tok.pc img { width: 100%; height: 100%; object-fit: cover; object-position: center 15%; transform: scale(1.4); transform-origin: center 20%; }
.tok.foe { border-style: dashed; }
.tok.me { box-shadow: 0 0 0 2px #fff; }
.tok.ally { box-shadow: 0 0 0 2px var(--ok); }
.explore { position: absolute; border-radius: 10px; border: 2px dashed var(--paper); background: var(--ink); color: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; padding: 2px; }
.explore.locked { border: 2px solid var(--danger); }
.explore .q { font-family: 'Bowlby One', sans-serif; font-size: 16px; line-height: 1; }
.teaser { position: absolute; top: 4%; left: 6%; right: 6%; padding: 14px; border-radius: 14px; background: var(--ink); border: 3px solid var(--accent); display: flex; flex-direction: column; gap: 6px; text-align: center; align-items: center; }
.teaser img { width: 120px; border: 2px solid var(--paper); transform: rotate(-3deg); }

/* Item cards (the Game Book's cut-out cards) */
.icard { position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; background: #fff; border: 1.5px dashed var(--ink); border-radius: 3px; overflow: hidden; color: var(--ink); }
.icard.w2 { aspect-ratio: 2; grid-column: span 2; }
.icard img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.icard.sel { outline: 4px solid var(--accent); outline-offset: -2px; }
.icard.used img { opacity: .35; }
.icard .udot { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; }
.icard .udot.on::after { content: ''; position: absolute; inset: 14%; border-radius: 50%; background: var(--ink); }
.icard.blank { background: repeating-linear-gradient(45deg, #fff 0 8px, #f3f0e8 8px 9px); }
.icard .iname { position: absolute; left: 3px; right: 3px; bottom: 4px; font-weight: 800; font-size: 11px; line-height: 1.05; text-align: center; background: rgba(255, 255, 255, .88); }
.icard:not(.blank) .iname { left: 0; right: 0; bottom: 0; min-height: 24%; display: grid; place-items: center; font-size: 10px; background: #fff; color: var(--ink); text-transform: uppercase; letter-spacing: .03em; }
.icard .udots { position: absolute; top: 8%; left: 0; right: 0; display: flex; justify-content: center; gap: 4%; }
.udot.inline { position: relative; display: inline-block; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; background: #fff; padding: 0; }
.udot.inline.big { width: 30px; height: 30px; }
.icard .udot.inline { width: 18%; height: auto; aspect-ratio: 1; transform: none; }
.udot.inline.on { background: var(--ink); }
.icard.cond { border: 2px solid var(--ink); background: var(--ink); }
.area { display: flex; flex-direction: column; gap: 6px; }
.slots { display: grid; gap: 5px; grid-auto-flow: dense; }
.slots.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .slots.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .slots.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.slot-empty { aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 3px; background: repeating-linear-gradient(-45deg, transparent 0 9px, rgba(0, 0, 0, .05) 9px 10px); }

/* Body parts */
.part { display: grid; grid-template-columns: auto 40px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed #c9c1ab; }
.part .pnum { background: var(--ink); color: #fff; font-family: 'Bowlby One', sans-serif; width: 1.6em; text-align: center; transform: rotate(-4deg); }
.part .pimg { width: 40px; height: 40px; overflow: hidden; display: block; } .part .pimg img { width: 220%; margin: -48% 0 0 -60%; }
.part.lost strong { text-decoration: line-through; color: var(--muted-dark); } .part.lost .pimg { opacity: .3; }
.bonebar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.bonebar span { height: 8px; border-radius: 4px; background: var(--bone-line); border: 1px solid var(--ink); }
.bonebar span.cracked { background: repeating-linear-gradient(90deg, var(--bone-line) 0 4px, var(--danger) 4px 6px); }
.bonebar span.gone { background: var(--danger); }

/* Dice */
.dice3d { display: flex; gap: 10px; perspective: 600px; flex-wrap: wrap; }
.d6 { --s: 36px; width: var(--s); height: var(--s); position: relative; display: inline-block; }
.d6 .cube { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(-18deg) rotateY(-22deg) rotateZ(var(--rz)) rotateX(var(--rx)) rotateY(var(--ry)); }
.d6 .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke='%23161310' stroke-linecap='round'%3E%3Cpath d='M3 6l3 1.5 1.5 3' stroke-width='.8'/%3E%3Cpath d='M37 31l-2.5.5-1 2.5' stroke-width='.8'/%3E%3Cpath d='M30 3l1 2.2M33 3.5l.6 1.6' stroke-width='.7'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat, radial-gradient(circle at 30% 25%, #fffcf2, #f1e9d6 55%, #dccfb3);
  box-shadow: inset 0 0 0 1.6px #161310, inset -2px -3px 5px rgba(60, 45, 20, .3); }
.d6 .face::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: rgba(0, 0, 0, .32); }
.d6[data-v="1"] .f1::before, .d6[data-v="2"] .f2::before, .d6[data-v="3"] .f3::before, .d6[data-v="4"] .f4::before, .d6[data-v="5"] .f5::before, .d6[data-v="6"] .f6::before { background: none; }
.d6 .face::after { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; font: 400 calc(var(--s) * .62) / 1 'Bowlby One', 'Arial Black', sans-serif; color: #fbf6ea; -webkit-text-stroke: calc(var(--s) * .04) #161310; paint-order: stroke fill; }
.d6 .f1::after { content: '1'; } .d6 .f2::after { content: '2'; } .d6 .f3::after { content: '3'; } .d6 .f4::after { content: '4'; } .d6 .f5::after { content: '5'; }
.d6 .f6::after { content: ''; inset: 6%; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 4.5c-8.3 0-13.5 5.6-13.5 12.8 0 4 1.9 6.7 4.2 8.3v4.6h18.6v-4.6c2.3-1.6 4.2-4.3 4.2-8.3C33.5 10.1 28.3 4.5 20 4.5z' fill='%23fbf6ea' stroke='%23161310' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M10.4 17.6c0-3 2.2-4.6 4.4-4.4 2.4.2 3.6 2.2 3.4 4.6-.2 2.4-1.8 4-4.2 4-2.2 0-3.6-1.7-3.6-4.2zM21.8 17.8c-.2-2.4 1-4.4 3.4-4.6 2.2-.2 4.4 1.4 4.4 4.4 0 2.5-1.4 4.2-3.6 4.2-2.4 0-4-1.6-4.2-4z' fill='%23161310'/%3E%3Cpath d='M20 22.2l-2.2 4.3h4.4z' fill='%23161310'/%3E%3Cpath d='M10.7 29.8h18.6v3.4c0 1.3-1 2.3-2.3 2.3H13c-1.3 0-2.3-1-2.3-2.3z' fill='%23fbf6ea' stroke='%23161310' stroke-width='1.6'/%3E%3Cpath d='M14.6 29.8v5.6M18 29.8v5.7M21.4 29.8v5.7M24.8 29.8v5.6' stroke='%23161310' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat; }
.d6.gold .face { background: radial-gradient(circle at 30% 25%, #fff2b8, #e8bf4e 45%, #b8862a 80%, #8a5f14); box-shadow: inset 0 0 0 1.6px #3a2a08, inset -2px -3px 5px rgba(60, 40, 0, .4); }
.d6.gold .face::after { font-size: calc(var(--s) * .44); -webkit-text-stroke-color: #2a1d04; color: #fff6d6; }
.d6.gold .f1::after { content: '10'; } .d6.gold .f2::after { content: '20'; } .d6.gold .f3::after { content: '30'; } .d6.gold .f4::after { content: '40'; } .d6.gold .f5::after { content: '50'; }
.d6.gold .f6::after { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M20 4.5c-8.3 0-13.5 5.6-13.5 12.8 0 4 1.9 6.7 4.2 8.3v4.6h18.6v-4.6c2.3-1.6 4.2-4.3 4.2-8.3C33.5 10.1 28.3 4.5 20 4.5z' fill='%23f3d27a' stroke='%232a1d04' stroke-width='1.8'/%3E%3Ccircle cx='14.6' cy='17.6' r='4' fill='%232a1d04'/%3E%3Ccircle cx='25.4' cy='17.6' r='4' fill='%232a1d04'/%3E%3Ccircle cx='14.6' cy='17.6' r='2.2' fill='%23e3241b'/%3E%3Ccircle cx='25.4' cy='17.6' r='2.2' fill='%23e3241b'/%3E%3Cpath d='M20 22.2l-2.2 4.3h4.4z' fill='%232a1d04'/%3E%3Cpath d='M10.7 29.8h18.6v3.4c0 1.3-1 2.3-2.3 2.3H13c-1.3 0-2.3-1-2.3-2.3z' fill='%23f3d27a' stroke='%232a1d04' stroke-width='1.6'/%3E%3Cpath d='M14.6 29.8v5.6M18 29.8v5.7M21.4 29.8v5.7M24.8 29.8v5.6' stroke='%232a1d04' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat; }
.d6 .f1 { transform: translateZ(calc(var(--s) / 2)); } .d6 .f6 { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.d6 .f3 { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); } .d6 .f4 { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.d6 .f5 { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); } .d6 .f2 { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.d6[data-v="6"]:not(.gold):not(.dim) { filter: drop-shadow(0 0 6px rgba(245, 224, 42, .9)); }
.d6.dim { opacity: .55; }
.d6.rolling { animation: hop 1s var(--delay) both cubic-bezier(.25, .6, .35, 1); }
.d6.rolling .cube { animation: tumble 1s var(--delay) both cubic-bezier(.2, .7, .3, 1); }
@keyframes tumble { from { transform: rotateX(-18deg) rotateY(-22deg) rotateZ(calc(var(--rz) + 260deg)) rotateX(calc(var(--rx) + 720deg)) rotateY(calc(var(--ry) - 540deg)); } to { transform: rotateX(-18deg) rotateY(-22deg) rotateZ(var(--rz)) rotateX(var(--rx)) rotateY(var(--ry)); } }
@keyframes hop { 0% { transform: translate(-40px, -46px); opacity: 0; } 12% { opacity: 1; } 45% { transform: translate(-8px, 0); } 62% { transform: translate(-3px, -10px); } 78%, 100% { transform: translate(0, 0); } }
.die-empty { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 2px dashed var(--muted-dark); border-radius: 8px; font-weight: 900; }
.dice-hero { display: flex; justify-content: center; gap: 18px; margin: 4px 0 18px; perspective: 600px; } .dice-hero .d6 { --s: 52px; }
.d63 { display: flex; align-items: center; gap: 14px; justify-content: space-between; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.d63 .d6 { --s: 44px; }
.rollbox .dice3d { padding-top: 8px; } .rollbox .logo { font-family: 'Bowlby One', sans-serif; }
.rollbox { border-radius: 14px; background: var(--ink); color: var(--paper); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 80px; }

/* Toast + overlays */
.toast { position: fixed; left: 12px; right: 12px; top: 64px; z-index: 50; padding: 12px 14px; border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 4px 4px 0 #000; border: 2px solid var(--ink); max-width: 560px; margin: 0 auto; }
.toast.error { border: 3px solid var(--danger); }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(10, 9, 8, 0.65); display: flex; align-items: flex-end; justify-content: center; }
.scrim.center { align-items: center; padding: 20px; }
.sheet { width: 100%; max-width: 560px; background: var(--paper); color: var(--ink); border-radius: 18px 18px 0 0; padding: 16px 14px 24px; display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow-y: auto; }
.scrim.center .sheet { border-radius: 18px; }
/* Sticker */
.stk-wrap { position: fixed; inset: 0; z-index: 90; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.stk { position: relative; width: min(88vw, 560px); aspect-ratio: 100 / 80; display: flex; align-items: center; justify-content: center; animation: stk-pop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both, stk-wiggle 0.8s ease-in-out 0.55s infinite; filter: drop-shadow(0 10px 24px rgba(0,0,0,0.55)); }
.stk-burst { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.stk-core { animation: stk-flash 0.32s steps(2, jump-none) infinite; }
.stk-text { position: relative; font-family: 'Jolly Lodger', 'Bowlby One', sans-serif; line-height: 0.9; color: #141312; text-align: center; transform: rotate(-8deg); -webkit-text-stroke: 1.5px #fbf8ef; text-shadow: 5px 5px 0 #fbf8ef; padding: 0 12%; letter-spacing: 0.02em; }
.stk-sub { position: absolute; bottom: 6%; left: 50%; transform: translateX(-50%) rotate(-3deg); white-space: nowrap; background: #141312; color: #f5e02a; font-weight: 800; font-size: clamp(14px, 4vw, 22px); padding: 6px 14px; border-radius: 999px; border: 2px solid #f5e02a; }
@keyframes stk-pop { 0% { transform: scale(0) rotate(-25deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes stk-wiggle { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(3deg) scale(1.06); } }
@keyframes stk-flash { 0% { fill: #f5e02a; } 100% { fill: #fff36b; } }
@media (prefers-reduced-motion: reduce) { .stk, .stk-core, .d6.rolling, .d6.rolling .cube { animation: none; } }
.conn { position: fixed; bottom: 8px; right: 8px; z-index: 70; padding: 6px 10px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.credit { font-size: 11px; color: var(--muted); text-align: center; padding: 6px; }
.drawer .logo, .sheet .logo, .paper .logo { color: var(--ink); }
.rollbox .logo { color: var(--accent); }
[hidden] { display: none !important; }
