/* helladnd: a tavern notice board. Cork, wood, pinned parchment. */
:root {
  --wood-900: #2a1a0e;
  --wood-800: #3b2414;
  --wood-700: #5a3a22;
  --wood-500: #8b5a2b;
  --cork: #b98b5e;
  --parchment: #f3e6c8;
  --parchment-2: #ead7ae;
  --parchment-edge: #cfb07a;
  --ink: #2b1d12;
  --ink-soft: #4a3423;
  --gold-text: #f7d98b;
  --red: #9b2d20;
  --green: #3c6b2f;
  --gold: #c9962b;
  --blue: #2f5f8a;
  --shadow: 0 2px 0 rgba(0, 0, 0, .15), 0 10px 24px rgba(30, 15, 5, .35);
  --radius: 6px;
  --font-display: 'Pirata One', 'IM Fell English SC', Georgia, serif;
  --font-label: 'IM Fell English SC', Georgia, serif;
  --font-body: 'Alegreya', Georgia, serif;
  --frame: clamp(6px, 1.5vw, 14px); /* wooden border round the page */
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 18px/1.5 var(--font-body);
  background-color: var(--cork);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(90, 58, 34, .28) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 80%, rgba(90, 58, 34, .22) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 60%, rgba(255, 240, 210, .18) 0 1px, transparent 2px);
  background-size: 7px 7px, 11px 11px, 13px 13px;
  border: var(--frame) solid var(--wood-800);
}

h1, h2 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; margin: 0; }
h2 { font-size: 1.9rem; }
h3 { font-family: var(--font-label); font-weight: 400; font-size: 1.2rem; margin: .9em 0 .25em; }
p { margin: .4em 0; }
.label { font-family: var(--font-label); font-size: 1.05rem; }
.hint { font-family: var(--font-body); font-size: .95rem; color: var(--ink-soft); }
.empty { font-style: italic; color: var(--ink-soft); }
.big { font-size: 1.3rem; font-weight: 600; }

/* ---------- buttons & inputs ---------- */
button {
  font: inherit; color: var(--ink); cursor: pointer;
  background: var(--parchment-2); border: 2px solid var(--wood-700); border-radius: var(--radius);
  padding: .3em .8em; min-height: 44px; min-width: 44px;
  touch-action: manipulation; /* no double-tap zoom swallowing repeated taps on iOS */
}
button:hover { background: #f8eccd; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
button.primary { background: var(--wood-700); color: var(--parchment); border-color: var(--wood-900); }
button.primary:hover { background: var(--wood-800); }
button.link { background: none; border: 0; text-decoration: underline; padding: 0 .2em; min-width: 0; }
input, select, textarea {
  font: inherit; font-family: var(--font-body); color: var(--ink); background: #fffaf0;
  border: 2px solid var(--wood-500); border-radius: var(--radius);
  padding: .35em .5em; min-height: 44px; width: 100%;
  touch-action: manipulation;
}
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--wood-700); flex: none; }
input[type=color] { padding: 2px; }
label { display: block; font-family: var(--font-label); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 8px 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.form-error { color: var(--red); font-weight: 700; min-height: 1.5em; }

/* list editors */
.list-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
.list-row > * { min-width: 0; }
.list-row input, .list-row select, .list-row textarea { flex-basis: 120px; }
.row-check { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 44px; font-family: var(--font-body); }
.remove-row { background: none; border-color: var(--parchment-edge); }

/* ---------- login & who ---------- */
.screen { display: flow-root; min-height: calc(100vh - 2 * var(--frame)); min-height: calc(100dvh - 2 * var(--frame)); }
.door { display: grid; place-items: center; padding: 16px; }
.door-sign {
  position: relative; background: var(--parchment); padding: 36px 24px 24px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow); text-align: center; border-radius: 3px;
}
.door-sign h1 { font-size: 3.4rem; color: var(--wood-800); }
.door-sign label { text-align: left; margin-top: 16px; }
.door-sign button { width: 100%; margin-top: 12px; }
.board-title {
  display: table; margin: 32px auto 0; padding: 6px 22px; border-radius: 8px;
  background: var(--wood-800); color: var(--gold-text); font-size: 2.6rem;
}
.who-list { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); max-width: 1000px; margin: 28px auto; padding: 0 16px; }
.who-pick {
  position: relative; display: block; text-align: left; background: var(--parchment); border: 0;
  border-top: 6px solid var(--pin); padding: 24px 18px 18px; box-shadow: var(--shadow); border-radius: 3px;
}
.who-pick strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; }

/* ---------- board ---------- */
#board { max-width: 1400px; margin: 0 auto; padding: 16px 16px 56px; }
.sign {
  position: relative; max-width: 760px; margin: 8px auto 28px; padding: 18px 16px 12px; text-align: center;
  color: var(--parchment); border-radius: 10px; box-shadow: var(--shadow);
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .08) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #6b4428, #4a2e1a);
}
.sign h1 { font-size: clamp(2.6rem, 8vw, 4.2rem); color: var(--gold-text); text-shadow: 0 2px 0 var(--wood-900); }
.sign p { font-size: 1.1rem; }
.sign-nav { display: flex; gap: 0 18px; justify-content: center; flex-wrap: wrap; font-size: 1rem; }
.sign-nav .link { color: var(--parchment); }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.section-head h2 { background: var(--wood-800); color: var(--gold-text); padding: 4px 16px; border-radius: 6px; }

/* pinned parchment notes */
.note {
  position: relative; background: var(--parchment); padding: 26px 20px 18px; border-radius: 3px; box-shadow: var(--shadow);
}
.note::before, .card::before, .who-pick::before, .door-sign::before {
  content: ''; position: absolute; top: 8px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, .7) 0 2px, var(--pin, var(--red)) 3px);
  box-shadow: 0 2px 2px rgba(0, 0, 0, .4);
}
.note ul { padding-left: 1.2em; margin: .3em 0; }
details.note > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
details.note > summary::-webkit-details-marker { display: none; }
details.note > summary::after { content: '▾'; font-size: 1.3rem; }
details.note:not([open]) > summary::after { content: '▸'; }

#status { margin-bottom: 36px; }
.status-grid { display: grid; gap: 20px; }
.note-quest { --pin: var(--red); }
.note-where { --pin: var(--blue); }
.note-loot { --pin: var(--gold); }
.note-npcs { --pin: var(--green); }
@media (min-width: 700px) {
  .status-grid { grid-template-columns: 1fr 1fr; }
  /* Wide screens always show every note open, so the summary is a plain heading there. */
  .status-grid > details.note > summary { pointer-events: none; cursor: default; }
  .status-grid > details.note > summary::after { display: none; }
}
@media (min-width: 1100px) {
  .status-grid { grid-template-columns: 2fr 1fr 1fr; }
  .note-quest { grid-row: span 2; }
  .note-npcs { grid-column: span 2; }
  .status-grid > :nth-child(odd) { transform: rotate(-.5deg); }
  .status-grid > :nth-child(even) { transform: rotate(.4deg); }
}
.quest { font-size: 1.25rem; }
.checks { list-style: none; padding: 0 !important; }
.checks label { display: flex; gap: .6em; align-items: center; min-height: 44px; font-family: var(--font-body); }
.checks .done { text-decoration: line-through; }
.tag { font-family: var(--font-label); font-size: .9rem; padding: 0 .45em; border-radius: 3px; color: #fff; }
.tag-ally { background: var(--green); }
.tag-enemy { background: var(--red); }
.tag-neutral { background: var(--wood-500); }

/* log book */
.logbook { margin-bottom: 36px; }
.entry { --pin: var(--wood-700); margin-bottom: 16px; }
.entry summary { font-size: 1.25rem; flex-wrap: wrap; justify-content: flex-start !important; }
.entry .num { font-family: var(--font-body); font-weight: 700; font-size: 1.4rem; color: var(--red); } /* body font: Pirata One "1" reads as "|" */
.entry .title { font-weight: 700; flex: 1 1 60%; min-width: 0; } /* beside the #; on phones the date drops below */
.entry .date { margin-left: auto; font-size: 1rem; }
.recap p { margin: .7em 0; }
.entry footer { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--parchment-edge); }
.chips { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips li { background: var(--parchment-2); border: 1px solid var(--wood-500); border-radius: 999px; padding: 0 .65em; font-size: .95rem; }

/* ---------- character cards ---------- */
.cards {
  display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -16px; padding: 18px 16px 24px;
}
.cards::-webkit-scrollbar { display: none; }
.card {
  position: relative; flex: 0 0 min(88%, 380px); scroll-snap-align: center;
  background: var(--parchment); padding: 28px 18px 16px; border-radius: 3px; box-shadow: var(--shadow);
  border-top: 6px solid var(--pin);
}
.card.is-me { outline: 3px solid var(--gold); outline-offset: 3px; }
.card-name { font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; line-height: 1.1; margin: 0; }
.card-sub { margin: 2px 0 0; }
.you { font-weight: 700; }
.hp { margin: 14px 0 10px; }
.hp-top { display: flex; justify-content: space-between; align-items: baseline; }
.hp-value { background: none; border: 0; padding: 0; font-size: 1.3rem; }
.hp-value strong { font-size: 1.9rem; }
.temp { color: var(--blue); font-size: 1rem; font-weight: 700; }
.hp-bar { height: 12px; background: var(--parchment-2); border-radius: 6px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3); }
.hp-bar span { display: block; height: 100%; background: var(--green); transition: width .3s; }
.hp-bar .mid { background: var(--gold); }
.hp-bar .low { background: var(--red); }
.steppers { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.steppers button { flex: 1; font-size: 1.4rem; line-height: 1; }
.steppers.small { margin: 0 0 0 auto; flex-wrap: nowrap; }
.steppers.small button { flex: none; width: 44px; font-size: 1.3rem; }
.hp-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hp-quick button { flex: 1 0 22%; }
dl { margin: 0; }
dt { font-family: var(--font-label); font-size: .95rem; }
dd { margin: 0; font-size: 1.4rem; font-weight: 700; }
.vitals, .abilities { display: grid; gap: 4px; text-align: center; padding: 10px 0; border-top: 1px solid var(--parchment-edge); }
.vitals { grid-template-columns: repeat(3, 1fr); }
.abilities { grid-template-columns: repeat(6, 1fr); }
.abilities dd small { display: block; font-size: .9rem; font-weight: 400; }
.resource, .slots { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-top: 1px solid var(--parchment-edge); }
/* Meter dots (span) are small; tappable dots (button) keep a 22px dot inside a 44px hit area. */
span.pip { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--wood-700); background: transparent; vertical-align: middle; }
span.pip + span.pip { margin-left: 8px; }
span.pip.on { background: var(--wood-700); }
button.pip { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; }
button.pip:hover { background: none; }
button.pip::before { content: ''; position: absolute; inset: 11px; border-radius: 50%; border: 2px solid var(--wood-700); background: transparent; }
button.pip.on::before { background: var(--wood-700); }
button.pip:hover::before { box-shadow: 0 0 0 3px var(--parchment-edge); }
.slot-row { display: inline-flex; align-items: center; gap: 0; margin-right: 10px; }
.slot-lvl { font-family: var(--font-label); margin-right: 2px; }
.card .chips li { background: #f7d2c8; border-color: var(--red); }
/* Inspiration + Rest share a row; Open sheet runs full width beneath them. */
.card-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.card-foot button { white-space: nowrap; padding-inline: .5em; }
.card-foot .primary { grid-column: 1 / -1; }
.insp.on { background: var(--gold); color: var(--wood-900); border-color: var(--wood-900); }
.dots { display: flex; justify-content: center; gap: 10px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--wood-800); opacity: .35; }
.dots span.active { opacity: 1; }
@media (min-width: 700px) {
  .cards { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; margin: 0; padding: 18px 4px 24px; }
  .dots { display: none; }
}
@media (min-width: 1100px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  .card { transition: transform .2s, box-shadow .2s; }
  .card:nth-child(odd) { transform: rotate(-.8deg); }
  .card:nth-child(even) { transform: rotate(.6deg); }
  .card:hover { transform: rotate(0) translateY(-4px); box-shadow: 0 16px 32px rgba(30, 15, 5, .45); }
}

/* ---------- dialogs: sheet & rest ---------- */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--parchment); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(20, 10, 4, .65); }
.sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
.sheet[open] { display: flex; flex-direction: column; }
@media (min-width: 900px) {
  .sheet { width: min(780px, 92vw); margin: 0 0 0 auto; border-left: 10px solid var(--wood-700); }
}
.sheet-head { padding: 16px 20px 8px; border-top: 8px solid var(--pin, var(--wood-700)); }
.sheet-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.close { font-size: 1.8rem; text-decoration: none !important; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tabs { display: flex; overflow-x: auto; gap: 2px; padding: 0 12px; border-bottom: 2px solid var(--wood-500); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; } /* the cut-off last tab already hints there is more to swipe */
.tabs button { flex: none; border: 0; border-bottom: 4px solid transparent; border-radius: 0; background: none; font-family: var(--font-label); font-size: 1.1rem; white-space: nowrap; }
.tabs [aria-selected="true"] { border-bottom-color: var(--wood-700); font-weight: 700; }
.tab-body { flex: 1; overflow-y: auto; padding: 16px 20px 40px; }
/* Sheet HP/Temp buttons: a 2×2 grid on phones, one row of four when there's room. */
.sheet .steppers:not(.small) { display: grid; grid-template-columns: 1fr 1fr; }
.sheet .steppers:not(.small) button { font-size: 1.15rem; white-space: nowrap; }
@media (min-width: 560px) { .sheet .steppers:not(.small) { grid-template-columns: repeat(4, 1fr); } }
.stat-row { display: flex; flex-wrap: wrap; gap: 14px 26px; padding: 6px 0; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.7rem; }
/* Six abilities: 3 + 3 on phones, one row of six on wider sheets (never a lone orphan). */
.ability-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); text-align: center; }
@media (min-width: 700px) { .ability-grid { grid-template-columns: repeat(6, 1fr); } }
.ability-grid > div { display: flex; flex-direction: column; align-items: center; }
.ability-grid b { font-size: 1.8rem; }
.ability-grid .save { font-size: .95rem; }
.skills { list-style: none; padding: 0; columns: 2 230px; column-gap: 28px; }
.skills li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--parchment-edge); break-inside: avoid; }
.skills small { font-size: .85rem; }
.skills select { width: auto; min-height: 36px; padding: 0 .3em; }
.condition-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; }
.condition-grid label { display: flex; gap: 8px; align-items: center; min-height: 40px; font-family: var(--font-body); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.feature { padding-bottom: 8px; border-bottom: 1px dashed var(--parchment-edge); }
.spell-list { list-style: none; padding: 0; }
.rest-dialog { width: calc(100vw - 32px); max-width: 480px; border-radius: 6px; }
.rest-form { padding: 20px; }
.rest-form h2 { margin-bottom: 8px; }
.rest-form fieldset { border: 0; padding: 0; margin: 12px 0; }
.rest-form legend { font-family: var(--font-label); font-size: 1.1rem; padding: 0; }
.rest-type label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-family: var(--font-body); }
.rest-type span { display: block; }
.hit-dice label { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-family: var(--font-body); }
.hit-dice input[type=number] { width: 90px; }
menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 16px 0 0; }

/* ---------- feedback ---------- */
.banner { position: sticky; top: 0; z-index: 10; background: var(--gold); color: var(--wood-900); text-align: center; padding: 8px 16px; font-weight: 700; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: min(92vw, 480px); pointer-events: none; }
.toast { background: var(--wood-800); color: var(--parchment); padding: 12px 16px; border-radius: 6px; box-shadow: var(--shadow); }
.toast-error { background: var(--red); color: #fff; }
.toast-success { background: var(--green); color: #fff; }
.shake { animation: shake .4s; }
.wobble::before { animation: wobble .6s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-25deg); } 60% { transform: rotate(15deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
  .card, .status-grid > * { transform: none !important; }
}
