
/* ==========================================================================
   Theme Tokens (CSS Variables)
   ========================================================================== */
:root {
  --bg: #f7f3e9;
  --text: #1f1d1a;
  --surface: #ffffff;
  --surface-2: #f0ece4;
  --border: #d8d2c4;
  --muted: #6b665e;
  --accent: #a66b2b;
  --accent-contrast: #ffffff;
  --link: #2a66c7;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.10);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-body: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-heading: var(--font-body);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
html[data-theme="dark"] {
  --bg: #1c1914;
  --text: #f3efe6;
  --surface: #26221b;
  --surface-2: #2e2a22;
  --border: #3a342a;
  --muted: #bdb6a8;
  --accent: #c1893a;
  --accent-contrast: #1b140c;
  --link: #7fb2ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.40);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.45);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #1c1914;
    --text: #f3efe6;
    --surface: #26221b;
    --surface-2: #2e2a22;
    --border: #3a342a;
    --muted: #bdb6a8;
    --accent: #c1893a;
    --accent-contrast: #1b140c;
    --link: #7fb2ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.40);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.45);
  }
}
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 160ms ease, color 160ms ease;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
button, .btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 120ms ease, background-color 160ms ease;
}
button:hover, .btn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
button:disabled, .btn:disabled { opacity: 0.65; cursor: not-allowed; }
input, select, textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  box-shadow: var(--shadow-sm) inset;
}
.card, .panel, .popover, .menu, .dropdown, .sheet, .toolbar, .tabbar {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.table, table {
  background: var(--surface);
  color: var(--text);
  border-collapse: collapse;
  width: 100%;
}
.table th, .table td, table th, table td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}
.bg-surface { background: var(--surface) !important; }
.bg-surface-2 { background: var(--surface-2) !important; }
.text-muted { color: var(--muted) !important; }
.border { border: 1px solid var(--border) !important; }
.radius-sm { border-radius: var(--radius-sm) !important; }
.radius-md { border-radius: var(--radius-md) !important; }
.radius-lg { border-radius: var(--radius-lg) !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }


/* Merged from html/css/style.css */
@font-face {
  font-family: 'castlestone';
  src: url('/fonts/CastleOfStonesRegular-rlg7.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'metamorphous';
  src: url('/fonts/Metamorphous-7wZ4.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'mountainking';
  src: url('/fonts/MountainKingRegular-woBYn.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'zelda';
  src: url('/fonts/TheWildBreathOfZelda-15Lv.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

:root {
  /* Base theme */
  --bg-color: #fdfaf5;
  --text-color: #2e2e2e;
  --accent-color: #9e7c4a;
  --border-color: #d6b179;

  /* Main tabs (used by character + wizard) */
  --tab-bg: #fffaf0;
  --tab-active-bg: #f2e7d5;
  --tab-hover-bg: rgba(0,0,0,0.06);

  /* Modal variables (your style.css references these) */
  --modal-tab-bg: #f4ede2;
  --modal-tab-active-bg: #e8ddcd;
  --modal-tab-hover-bg: #e0d6c3;
  --modal-btn-bg: #f5f0e8;
  --modal-btn-hover-bg: #e2d8cb;
  --modal-close-color: #333;
  --modal-close-hover-color: #000;
}

[data-theme="dark"] {
  --bg-color: #1e1e1e;
  --text-color: #f0e6d2;
  --accent-color: #d4a55d;
  --border-color: #5a442a;

  --tab-bg: #2a2a2a;
  --tab-active-bg: #343434;
  --tab-hover-bg: #444444;

  --modal-tab-bg: #2c2c2c;
  --modal-tab-active-bg: #3a3a3a;
  --modal-tab-hover-bg: #444444;
  --modal-btn-bg: #3a3a3a;
  --modal-btn-hover-bg: #4a4a4a;
  --modal-close-color: #f0e6d2;
  --modal-close-hover-color: #ffffff;
}

.modal-overlay {
   position: fixed; inset: 0; display: grid; place-items: center;
   background: rgba(0,0,0,.45);
   z-index: 2000;
}
.modal {
   width: min(820px, 92vw);
   background: var(--bg-color); color: var(--text-color);
   border: 1px solid var(--border-color);
   border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
   padding: 16px;
}
.modal-header { display:flex; justify-content:space-between; align-items:center;
   border-bottom: 1px solid rgba(0,0,0,.1); padding-bottom: 8px; margin-bottom: 12px; }
.close-btn { background:transparent; border:none; font-size:24px; cursor:pointer; }

.modal-tabs { 
  display: flex; 
  gap: 8px; 
  margin-bottom: 12px; 
}

.tab-btn { 
  border: 1px solid rgba(0,0,0,.15); 
  background: var(--modal-tab-bg);
  padding: 8px 12px; 
  border-radius: 999px; 
  cursor: pointer; 
  color: var(--text-color);
  transition: background-color 0.2s;
}

.tab-btn.active { 
  border-color: var(--modal-tab-active-bg); 
  font-weight: 600; 
}

.tab-btn:hover {
  background-color: var(--modal-tab-hover-bg);
}

.tab-panel { display:none; }
.tab-panel.active { display:block; }

.theme-group { display:grid; grid-template-columns: repeat(2, minmax(220px,1fr)); gap:12px; margin:12px 0; }
.theme-group h4 { grid-column: 1 / -1; margin:6px 0; }

.form-grid { display:grid; gap:12px; }
.form-inline { display:flex; gap:8px; align-items:center; }

.modal-actions { margin-top:12px; display:flex; gap:8px; justify-content:flex-end; }
.btn { padding:8px 12px; border-radius:10px; border:1px solid rgba(0,0,0,.15); cursor:pointer; }
.btn.primary { border-color:transparent; background:#7aa2ff; }
.btn.ghost { 
  background: var(--modal-btn-bg); 
  color: var(--text-color);
}
.btn.ghost:hover {
  background: var(--modal-btn-hover-bg);
}

.btn.danger { background:#ff6b6b; border-color:transparent; color:#fff; }

.close-btn {
  font-size: 24px;
  line-height: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--modal-close-color);
  transition: color 0.2s ease;
}
.close-btn:hover {
  color: var(--modal-close-hover-color);
}

.form-msg { display:block; margin-top:8px; }
.muted { opacity:.7; }

body {
  margin: 0;
  font-family: 'metamorphous', serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

body::before, body::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

body::before {
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.2);
}

body::after {
  background: radial-gradient(circle at top left, rgba(0,0,0,0.1), transparent 70%),
              radial-gradient(circle at bottom right, rgba(0,0,0,0.1), transparent 70%);
}




/* Merged from html/css/dice_roller.css */

#dice-roller-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f5f5f5;
  border-top: 2px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 1rem;
  padding: 0.5rem 1rem;
  z-index: 9999;
}

.hidden {
  display: none !important;
}

.dice-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

#dice-roller-bar input[type="number"] {
  padding: 2px;
}

input.dice-count {
  width: 3ch;
  max-width: 50px;
}

input.dice-mod {
  width: 2ch;
  max-width: 30px;
}

#dice-roller-bar button {
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.9rem;
}

#dice-results {
  width: fit-content;
  position: fixed;
  bottom: 70px;
  left: 50%;
  background: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  max-height: 200px;
  max-width: 90vw;
  overflow-y: auto;
  font-size: 0.9rem;
  z-index: 9999;
  transform: translateX(-50%);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  white-space: nowrap;
}

#dice-history {
  display: none;
  position: fixed;
  bottom: 60px;
  left: 0;
  background: white;
  border: 1px solid #999;
  padding: 0.5rem;
  max-height: 250px;
  width: 300px;
  overflow-y: auto;
  z-index: 9998;
}


/* ==========================================================================
   Home (index.html) baseline
   ========================================================================== */
#signin-btn,
.signin-button {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

#signin-btn:hover,
.signin-button:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

#navigation-bar {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
}

#navigation-bar button,
#navigation-bar a {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  text-decoration: none;
}

#navigation-bar button:hover,
#navigation-bar a:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
