/* Fawnalore Tracker — domino tile look, mobile-first, big thumbs */
:root {
  --bg: #221c18;
  --parchment: #F2E8D4;
  --parchment-shadow: #d9cbab;
  --ink: #1E1B16;
  --hp: #B3243F;        /* crimson banner from the physical tile */
  --hp-deep: #7f1830;
  --ether: #1A8A9D;     /* teal banner */
  --ether-deep: #0e5f6e;
  --pin: #C87A5A; --vul: #D65F78; --mark: #F0BE5A; --guard: #8FB87E;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Averia Libre', Georgia, serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 30% 10%, rgba(120,60,50,.25), transparent 55%),
                    radial-gradient(ellipse at 80% 90%, rgba(30,80,90,.2), transparent 50%);
  color: var(--parchment);
  touch-action: manipulation;          /* kills double-tap zoom */
  user-select: none;
  display: flex; flex-direction: column; min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
.top { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem .4rem; }
.logo { font-family: 'Permanent Marker', cursive; font-size: 1.2rem; }
.turn { margin-left: auto; opacity: .85; }
.reset { font-family: inherit; background: none; border: 1px solid rgba(242,232,212,.4); color: var(--parchment); border-radius: 999px; padding: .25rem .8rem; }

.ribbon {
  margin: .3rem .8rem; padding: .6rem .9rem; border-radius: var(--radius);
  background: var(--parchment); color: var(--ink); font-size: .95rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  animation: drop .25s ease-out;
}
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

main { flex: 1; padding: .4rem .8rem 5.5rem; max-width: 560px; width: 100%; margin: 0 auto; }

/* Domino */
.domino { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.panel {
  background: var(--parchment);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 var(--parchment-shadow), 0 8px 20px rgba(0,0,0,.45);
  overflow: hidden; display: flex; flex-direction: column;
  color: var(--ink);
}
.banner {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  font-family: 'Permanent Marker', cursive; font-size: 1.15rem; letter-spacing: .06em;
  color: var(--parchment); padding: .45rem .5rem; text-transform: uppercase;
}
.hp-banner { background: linear-gradient(180deg, var(--hp), var(--hp-deep)); }
.ether-banner { background: linear-gradient(180deg, var(--ether), var(--ether-deep)); }
.banner .icon { width: 1.3em; height: 1.3em; object-fit: contain; }

.tapzone {
  font-family: 'Averia Libre', serif; font-weight: 700;
  border: none; background: transparent; color: rgba(30,27,22,.42);
  font-size: 1.9rem; line-height: 1; padding: .55rem 0; cursor: pointer;
}
.tapzone:active { background: rgba(30,27,22,.08); color: var(--ink); }
.value {
  font-family: 'Permanent Marker', cursive;
  font-size: clamp(3rem, 16vw, 4.4rem); text-align: center; line-height: 1;
  padding: .1rem 0;
}
.value.bump-up { animation: bumpUp .18s ease-out; }
.value.bump-down { animation: bumpDown .18s ease-out; }
@keyframes bumpUp { 50% { transform: scale(1.12); } }
@keyframes bumpDown { 50% { transform: scale(.9); } }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .6rem; }
.chip {
  font-family: inherit; font-size: .85rem; font-weight: 700;
  border: none; border-radius: 999px; padding: .38rem .8rem; cursor: pointer;
  color: var(--ink);
}
.chip.add { background: transparent; border: 1.5px dashed rgba(242,232,212,.55); color: var(--parchment); font-weight: 400; }
.monster-card .chip.add { border-color: rgba(30,27,22,.4); color: var(--ink); }
.chip.s-pinned { background: var(--pin); }
.chip.s-vulnerable { background: var(--vul); color: #fff; }
.chip.s-marked { background: var(--mark); }
.chip.s-guard { background: var(--guard); }

/* Monsters */
.section-title { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 1.05rem; margin: 1.3rem 0 .5rem; opacity: .9; }
.monster-card {
  background: var(--parchment); color: var(--ink);
  border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .6rem;
  box-shadow: 0 3px 0 var(--parchment-shadow), 0 6px 16px rgba(0,0,0,.4);
}
.monster-head { display: flex; align-items: center; gap: .6rem; }
.monster-head .shape {
  font-size: 1.95rem; line-height: 1; color: var(--parchment);
  width: 2.9rem; height: 2.9rem; min-width: 2.9rem; display: grid; place-items: center;
  background: var(--ink); border-radius: 10px;
}
.monster-head input {
  font-family: inherit; font-size: 1rem; font-weight: 700; border: none;
  background: transparent; flex: 1; min-width: 0; color: var(--ink);
  border-bottom: 1px dashed rgba(30,27,22,.25); padding: .15rem 0;
}
.monster-head .remove { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: rgba(30,27,22,.5); padding: .2rem .4rem; }
.monster-hp { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; }
.monster-hp .mz {
  font-size: 1.6rem; font-weight: 700; border: none; background: rgba(30,27,22,.07);
  border-radius: 10px; width: 3.2rem; height: 2.7rem; cursor: pointer; color: var(--ink);
}
.monster-hp .mz:active { background: rgba(30,27,22,.16); }
.monster-hp .mv { font-family: 'Permanent Marker', cursive; font-size: 1.9rem; flex: 1; text-align: center; }
.monster-hp .hp-tag { font-size: .75rem; opacity: .6; }
.slot-adders { display: flex; gap: .5rem; }
.slot-add .shape { font-size: 1.9rem; color: var(--parchment); display: block; line-height: 1; }
.slot-add {
  flex: 1; font-family: inherit; font-size: .95rem;
  background: transparent; color: var(--parchment);
  border: 1.5px dashed rgba(242,232,212,.5); border-radius: var(--radius);
  padding: .6rem 0; cursor: pointer;
}
.slot-add:disabled { opacity: .3; }
.slot-hint { font-size: .75rem; opacity: .55; text-align: center; margin-top: .4rem; }

/* End turn */
.end-turn {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(.8rem + env(safe-area-inset-bottom));
  font-family: 'Permanent Marker', cursive; font-size: 1.15rem;
  background: var(--accent); color: var(--parchment); border: 2px solid rgba(242,232,212,.5);
  border-radius: 999px; padding: .75rem 2.2rem; cursor: pointer;
  box-shadow: 0 4px 0 var(--parchment-shadow), 0 10px 24px rgba(0,0,0,.5);
}
.end-turn:active { transform: translateX(-50%) translateY(2px); box-shadow: 0 2px 0 var(--parchment-shadow); }

/* Sheet */
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; z-index: 20;
}
.sheet-card {
  background: var(--parchment); color: var(--ink); width: 100%;
  border-radius: var(--radius) var(--radius) 0 0; padding: 1rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom));
  max-height: 75dvh; overflow: auto;
}
.sheet-title { font-family: 'Permanent Marker', cursive; font-weight: 400; margin: 0 0 .6rem; }
.state-option {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 1rem;
  background: rgba(30,27,22,.05); border: none; border-radius: 10px;
  padding: .7rem .8rem; margin-bottom: .5rem; cursor: pointer; color: var(--ink);
}
.state-option b { display: inline-block; min-width: 6.2rem; }
.state-option small { color: rgba(30,27,22,.65); display: block; margin-top: .15rem; }
.guard-row { display: flex; gap: .5rem; }
.guard-row .state-option { flex: 1; text-align: center; }
.sheet-close { font-family: inherit; width: 100%; background: var(--ink); color: var(--parchment); border: none; border-radius: 10px; padding: .7rem; margin-top: .3rem; cursor: pointer; }
.sheet-def { white-space: pre-wrap; line-height: 1.45; }
.sheet-remove { font-family: inherit; width: 100%; background: var(--hp); color: #fff; border: none; border-radius: 10px; padding: .7rem; margin-top: .8rem; cursor: pointer; }

.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
@media (min-width: 640px) { .value { font-size: 4.6rem; } }

/* ---- character select ---- */
.char-select { padding: 2rem 1.1rem calc(2rem + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.cs-title { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 1.7rem; margin: 1rem 0 .3rem; }
.cs-sub { color: rgba(242,232,212,.7); margin: 0 0 1.3rem; }
.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.char-pick {
  --c: #333; --ct: #999;
  font-family: inherit; text-align: left; cursor: pointer; color: var(--parchment);
  background: linear-gradient(150deg, var(--c), rgba(0,0,0,.35));
  border: 2px solid var(--ct); border-radius: 16px; padding: 1rem .9rem 1.1rem;
  display: flex; flex-direction: column; gap: .2rem; min-height: 6.5rem;
}
.char-pick:active { transform: scale(.98); }
.char-name { font-family: 'Permanent Marker', cursive; font-size: 1.4rem; }
.char-class { font-size: .82rem; opacity: .85; }
.char-saved { font-size: .78rem; margin-top: auto; color: var(--ct); font-weight: 700; }
.char-saved.new { opacity: .7; font-weight: 400; font-style: italic; }

/* ---- header additions ---- */
.who { display: flex; align-items: center; gap: .5rem; background: none; border: none; color: var(--parchment); font-family: inherit; cursor: pointer; padding: .2rem; }
.who-dot { width: .85rem; height: .85rem; border-radius: 50%; background: var(--accent); border: 2px solid rgba(242,232,212,.6); }
.who b { font-size: 1rem; } .who small { display: block; opacity: .7; font-size: .72rem; }
.top-actions { margin-left: auto; display: flex; gap: .25rem; }
.ico {
  font-family: inherit; font-size: 1.1rem; width: 2.3rem; height: 2.3rem; border-radius: 10px;
  background: rgba(242,232,212,.08); border: 1px solid rgba(242,232,212,.25); color: var(--parchment); cursor: pointer;
}
.ico.on { background: var(--accent); border-color: var(--accent); }
.turn { margin-left: .6rem; opacity: .85; }

/* ---- undo ---- */
.undo {
  display: block; margin: .3rem auto 0; font-family: inherit; font-size: .85rem;
  background: rgba(242,232,212,.1); border: 1px solid rgba(242,232,212,.3);
  color: var(--parchment); border-radius: 999px; padding: .3rem .9rem; cursor: pointer;
}

/* ---- event note ---- */
.event-note {
  width: 100%; margin-top: .6rem; font-family: inherit; font-size: .9rem;
  background: rgba(255,252,242,.12); color: var(--parchment);
  border: 1px dashed rgba(242,232,212,.35); border-radius: 10px; padding: .5rem .7rem;
}
.event-note::placeholder { color: rgba(242,232,212,.5); }

/* ---- dice ---- */
.dice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.dice-btn {
  font-family: 'Permanent Marker', cursive; font-size: 1.2rem; padding: .8rem 0;
  background: var(--accent); color: var(--parchment); border: none; border-radius: 12px; cursor: pointer;
}
.dice-result { text-align: center; margin-top: 1rem; min-height: 3.5rem; }
.roll-num { display: block; font-family: 'Permanent Marker', cursive; font-size: 3rem; color: var(--ink); line-height: 1; }
.dice-result small { color: rgba(30,27,22,.6); }
