/* ==========================================================
   Redwood Frontier - base styles (tokens, buttons, dialogs, toasts)
   Shared by every page.
   ========================================================== */

:root {
  --ink:        #1b0f0a;
  --wood-900:   #22130d;
  --wood-800:   #2f1c12;
  --wood-700:   #432919;
  --wood-600:   #5b3a24;
  --cream:      #ecd5b2;
  --cream-dim:  #c9ac84;
  --sand:       #d9b98a;
  --orange:     #e8873a;
  --orange-hot: #f2a14c;
  --rust:       #b8451f;
  --error:      #ff8a6b;
  --ok:         #a9d18e;

  --font-display: "Rye", "Rockwell", "Georgia", serif;
  --font-body:    "Special Elite", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--cream);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 400; font-family: var(--font-display); }
p { margin: 0; }
code { font-family: var(--font-body); color: var(--orange-hot); }
.muted { color: var(--cream-dim); }

/* ---------- Background ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    linear-gradient(to bottom,
      #1a1229 0%, #3b2342 24%, #7a3a44 50%, #b8602f 74%, #d98f48 100%);
}
.scene::after {                 /* darken so content stays readable */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(14, 7, 4, .55), rgba(14, 7, 4, .86) 70%);
}
.mesa { position: absolute; left: 0; width: 100%; display: block; }
.mesa-back  { bottom: 6%;  height: 30vh; fill: #5a2a30; opacity: .7; }
.mesa-front { bottom: 0;   height: 22vh; fill: #2e1517; }


/* ---------- Page container ---------- */
.page {
  position: relative;
  z-index: 1;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 30px clamp(14px, 4vw, 36px) 26px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--orange);
}


/* ---------- Wood surfaces ---------- */
.panel,
.char-card {
  position: relative;
  border-radius: 10px;
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 61px, rgba(0, 0, 0, .3) 61px, rgba(0, 0, 0, .3) 63px),
    repeating-linear-gradient(95deg, rgba(255, 210, 160, .03) 0, rgba(255, 210, 160, .03) 2px, transparent 2px, transparent 9px),
    linear-gradient(to bottom, var(--wood-700), var(--wood-800) 60%, var(--wood-900));
  border: 3px solid #120905;
  box-shadow:
    0 0 0 2px var(--wood-600),
    0 0 0 5px #120905,
    inset 0 2px 0 rgba(255, 220, 170, .12),
    inset 0 -16px 34px rgba(0, 0, 0, .3),
    0 20px 40px rgba(8, 3, 1, .5);
}


/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding: 0 22px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  color: #fff3dd;
  text-shadow: 0 2px 0 rgba(90, 30, 8, .8);
  background: linear-gradient(to bottom, var(--orange-hot), var(--orange) 45%, var(--rust));
  border: 2px solid #120905;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255, 235, 190, .5), inset 0 -3px 0 rgba(90, 30, 8, .45), 0 5px 0 #120905, 0 10px 16px rgba(0, 0, 0, .4);
  transition: transform .12s, box-shadow .12s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 235, 190, .4), inset 0 -2px 0 rgba(90, 30, 8, .45), 0 2px 0 #120905, 0 5px 8px rgba(0, 0, 0, .4); }
.btn:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); pointer-events: none; }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }

.btn-ghost {
  color: var(--cream);
  text-shadow: none;
  background: linear-gradient(to bottom, var(--wood-600), var(--wood-700));
  box-shadow: inset 0 2px 0 rgba(255, 220, 170, .18), inset 0 -3px 0 rgba(0, 0, 0, .35), 0 5px 0 #120905, 0 10px 16px rgba(0, 0, 0, .4);
}
.btn-danger { background: linear-gradient(to bottom, #e0603f, #b8321a 60%, #8a2410); }


/* ---------- Dialogs ---------- */
dialog {
  width: min(94vw, 520px);
  max-height: 92vh;
  padding: 0;
  overflow: auto;
  color: var(--cream);
  font-family: var(--font-body);
  background:
    repeating-linear-gradient(95deg, rgba(255, 210, 160, .03) 0, rgba(255, 210, 160, .03) 2px, transparent 2px, transparent 9px),
    linear-gradient(to bottom, var(--wood-700), var(--wood-800) 60%, var(--wood-900));
  border: 3px solid #120905;
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--wood-600), 0 0 0 6px #120905, 0 30px 70px rgba(0, 0, 0, .7);
}
dialog[open] { animation: pop .25s cubic-bezier(.2, .8, .2, 1); }
dialog::backdrop { background: rgba(8, 3, 1, .72); backdrop-filter: blur(2px); }

.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.dlg-head h3 { font-size: 24px; text-shadow: 0 2px 0 #120905; }
.dlg-x { width: 36px; height: 36px; font-size: 26px; line-height: 1; color: var(--cream-dim); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.dlg-x:hover, .dlg-x:focus-visible { color: var(--orange-hot); outline: none; }
.dlg-body { padding: 16px 20px 6px; }
.dlg-body > p { margin-bottom: 14px; line-height: 1.5; color: var(--cream-dim); }
.dlg-body > p b { color: var(--cream); font-weight: 400; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 12px 20px 22px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { display: block; margin-bottom: 6px; padding: 0; font-size: 13.5px; color: var(--sand); }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0 12px;
  font: inherit;
  font-size: 16px;
  color: var(--cream);
  background: rgba(10, 4, 2, .6);
  border: 2px solid #120905;
  border-radius: 6px;
  outline: none;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 220, 170, .1);
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"], input[type="password"], input[type="number"], select { height: 46px; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--cream-dim) 50%), linear-gradient(135deg, var(--cream-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--wood-800); color: var(--cream); }
textarea { padding: 10px 12px; resize: vertical; min-height: 96px; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: rgba(201, 172, 132, .5); }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: inset 0 3px 8px rgba(0, 0, 0, .55), 0 0 0 3px rgba(232, 135, 58, .25); }
.field.invalid input, .field.invalid select { border-color: var(--error); }

.hint { margin-top: 5px; font-size: 12.5px; color: var(--error); }
.hint:empty { display: none; }
.form-hint { margin: 0 0 10px; text-align: center; }
.count { margin-top: 4px; text-align: right; font-size: 12px; color: var(--cream-dim); }
.name-preview { margin: -2px 0 14px; font-size: 13px; color: var(--cream-dim); }

.gender { display: flex; gap: 12px; flex-wrap: wrap; }
.gender legend { width: 100%; }
.radio { display: inline-flex !important; align-items: center; gap: 8px; margin: 0 !important; cursor: pointer; }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio span {
  padding: 9px 20px;
  font-size: 14px;
  color: var(--cream-dim);
  background: rgba(10, 4, 2, .55);
  border: 2px solid #120905;
  border-radius: 6px;
  transition: all .2s;
}
.radio input:checked + span { color: var(--ink); background: var(--orange-hot); border-color: var(--orange-hot); }
.radio input:focus-visible + span { outline: 2px solid var(--cream); outline-offset: 2px; }


/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(92vw, 340px); }
.toast {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--cream);
  background: linear-gradient(to bottom, var(--wood-700), var(--wood-800));
  border: 3px solid #120905;
  border-left: 6px solid var(--orange);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
  animation: toastIn .3s both;
}
.toast.ok { border-left-color: #7fd35e; }
.toast.err { border-left-color: var(--error); }
.toast.out { animation: toastOut .3s both; }


/* ---------- Shared animations ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(26px); } }

/* ---------- Shared responsive ---------- */
@media (max-width: 600px) {
  .two { grid-template-columns: 1fr; gap: 0; }
  .toasts { right: 4vw; left: 4vw; width: auto; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot { flex-direction: column-reverse; }
  .dlg-foot .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
