/* Shared dark-fantasy finish. Loaded after the existing desktop and mobile CSS.
   The party backdrop is configured separately; this file only styles UI surfaces. */
:root {
  --bg: #0e1613;
  --panel: #13201b;
  --input: #0e1915;
  --text: #e5deca;
  --muted: #a7ada1;
  --accent: #a88b57;
  --line: #405047;
  --panel-raised: #1c2d26;
  --accent-text: #d2b474;
  --success: #79a58b;
  --danger: #b96568;
  --violet: #a18ac3;
  --discovery: #7899b0;
}

body { color: var(--text); }
a { color: var(--accent-text); }
a:hover { color: #e1c995; }
label, .creation-intro > p:last-child, #class-details { color: #c4c7b8; }
.hint, .muted, .panel-help, .die-note, .rail-caption { color: var(--muted); }
.eyebrow, .section-caption, .field-label { color: var(--accent-text); }
header { border-bottom-color: #a88b5738; }

/* The same restrained material on creation, lobby, play, and dialog surfaces. */
.panel, .room-forms form, #create-form, #resume-form, .class-portrait,
.chat-panel, .chronicle-panel, .die-window, .turn-window,
.modal-card, .drawer aside, .game-menu-dialog, #hero-code-dialog,
#recovery-dialog, .sound-panel {
  background: linear-gradient(155deg, #1c2d26f0 0%, #13201bf5 74%);
  border-color: #a88b5752;
  box-shadow: inset 0 1px 0 #e5deca0a, 0 8px 24px #03090626;
  color: var(--text);
}

.class-card, .hero-card, .profile-section, .creator-player-controls,
.inventory-slots li, .inventory-slots .occupied {
  background: linear-gradient(155deg, #20342ac7, #13201bef);
  border-color: #a88b5740;
  box-shadow: inset 0 1px 0 #e5deca08;
  color: var(--text);
}
.class-card.selected, .hero-card.selected { border-color: var(--accent); }
.hero-card.me {
  background: linear-gradient(155deg, #2a3c2de8, #1b2d22f2);
  border-color: #c5a66b99;
}
.hero-card .avatar { background-color: #d2b4740d; }
.hero-color-swatch { border-color: #e5deca80; }
.hero-card .hp-bar { background: #314037; }
.hero-card .hp-bar i { background: linear-gradient(90deg, #628a74, var(--success)); }
.hero-card.dead .hp-bar i { background: #8c5057; }
.status.ready, .status.ready i { color: #a3c6ad; }
.status.ready i { background: var(--success); }
.status.dead, .status-dead, .death-note { color: #d49a9c; }
.status.dead i { background: var(--danger); }
.inventory-slots .empty { color: var(--muted); }
.slot-number, .profile-section h3 { color: var(--accent-text); }
.profile-health { color: #a3c6ad; }
.check-table th, .check-table td:last-child { color: var(--muted); }
.check-table td, .check-table th { border-bottom-color: #a88b5738; }
.check-table td:nth-child(3) { color: var(--accent-text); }

/* The journal stays opaque enough for long-form reading over the party scene. */
.journal-heading {
  background: linear-gradient(160deg, #26392d, #1c2d26);
  border-color: #a88b5766;
  color: var(--accent-text);
  box-shadow: inset 0 1px 0 #e5deca0a;
}
#log {
  background: linear-gradient(165deg, #182820f8 0%, #111e19fa 80%);
  border-color: #a88b5766;
  border-top-color: #a88b573d;
  box-shadow: inset 0 1px 0 #e5deca0a, 0 10px 30px #0309062e;
  color: var(--text);
  scrollbar-color: #6c795f #111e19;
}
#log .game-master:not(.hero-paragraph), #log .dice-card p { color: var(--text); }
#log .system, #log .check { color: var(--muted); }
#log .round-title, #log .round-done, #chronicle .round-title { color: var(--accent-text); }
#log .round-title::after { background: #a88b5747; }
#log .quote { color: #b7bcaf; }
/* Server-assigned six-player identity palette remains distinct. A neutral blend
   softens its saturation in story text without remapping or merging players. */
#log .quote-name, #log .game-master.hero-paragraph {
  color: color-mix(in srgb, var(--hero-color, #e5deca) 76%, var(--muted));
}
#log .quote, #log .game-master.hero-paragraph {
  border-left-color: color-mix(in srgb, var(--hero-color, #a88b57) 68%, var(--line));
}
#log .dice-card {
  background: #1c2d26a8;
  border-color: #52604e;
  box-shadow: inset 0 1px 0 #e5deca08;
}
#log .tone-success, #log .tone-crit-success { border-left-color: var(--success); background: #79a58b12; }
#log .tone-failure, #log .tone-crit-failure { border-left-color: var(--danger); background: #b9656812; }
#log .tone-discovery { border-left-color: var(--discovery); background: #7899b012; }
#log .tone-loot { border-left-color: var(--violet); background: #a18ac312; }
#log .tone-important { border-left-color: var(--accent); border-top-color: #a88b5766; border-bottom-color: #a88b5766; background: #a88b5712; }
#log .tone-combat { border-left-color: #c38e6f; background: #c38e6f12; }
#log .tone-death { border-color: #8c5057; border-left-color: var(--danger); background: #8c505721; }
#log :is(.tone-success, .tone-crit-success) :is(.dice-kicker, .dice-result) { color: #a3c6ad; }
#log :is(.tone-failure, .tone-crit-failure, .tone-death) :is(.dice-kicker, .dice-result) { color: #d49a9c; }
#log .tone-discovery :is(.dice-kicker, .dice-result) { color: #aac3d1; }
#log .tone-loot :is(.dice-kicker, .dice-note) { color: #c5b4d8; }
#log .tone-important :is(.dice-kicker, .dice-result) { color: #ddc48d; }
#log .tone-combat :is(.dice-kicker, .dice-result) { color: #d4a98e; }
#log .harm, #chronicle .harm, .enemy-stats { color: #d49a9c; }
.enemy-stats { border-color: #8c505780; background: #341f23d9; }
.combat-event { color: #c7beb0; }

/* Controls keep their existing dimensions, disabled rules, and responsive flow. */
button {
  background-color: #263a30;
  border-color: #a88b575e;
  color: var(--text);
  transition: background-color .18s ease, border-color .18s ease,
              box-shadow .18s ease, color .18s ease;
}
button:not(:disabled):hover {
  filter: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px #a88b572e, 0 0 12px #a88b572e;
}
button:disabled:hover { filter: none; }
.ghost-button, .side-rail .ghost-button { color: var(--muted); }
.ghost-button:not(:disabled):hover, .side-rail .ghost-button:not(:disabled):hover { color: var(--accent-text); }
.rail-button { background: #203228; border-color: #a88b5752; }
#ready-button, #start-adventure, #create-form button[type="submit"],
#join-room-form button[type="submit"], #create-room-form button[type="submit"],
#chat-form button[type="submit"] {
  background: var(--accent);
  color: #0e1613;
  border-color: var(--accent);
}
#ready-button:not(:disabled):hover, #start-adventure:not(:disabled):hover,
#create-form button[type="submit"]:not(:disabled):hover,
#join-room-form button[type="submit"]:not(:disabled):hover,
#create-room-form button[type="submit"]:not(:disabled):hover,
#chat-form button[type="submit"]:not(:disabled):hover { background: #bca16e; }
input, select, textarea {
  background-color: var(--input);
  border-color: #6c795f;
  color: var(--text);
  caret-color: var(--accent-text);
  color-scheme: dark;
  transition: background-color .18s ease, border-color .18s ease,
              box-shadow .18s ease;
}
input::placeholder, textarea::placeholder { color: #9ba99a; opacity: 1; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px #a88b5752;
}
:focus-visible { outline-color: var(--accent-text); }
.action-dock {
  background: linear-gradient(0deg, #0e1613 0%, #0e1613f7 72%, #0e161300);
}
.action-dock input { background: #0e1915; border-color: #6c795f; }
.action-dock input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #a88b5752; }
.action-dock .hint { color: #b4bcac; }
#chat-messages { color: var(--text); scrollbar-color: #6c795f #13201b; }
#chat-messages strong { color: var(--accent-text); }
#chronicle { scrollbar-color: #6c795f #13201b; }
#chronicle p { border-bottom-color: #a88b5729; }
#desktop-chat-toggle { background: #203228ed; border-color: var(--accent); color: var(--accent-text); }

.modal { background: #06100bc7; }
.drawer { background: #06100b9c; }
.game-menu-dialog::backdrop, #hero-code-dialog::backdrop,
#recovery-dialog::backdrop { background: #06100bc7; }
.game-menu-head { background: #1c2d26; }
.game-menu-dialog h3 { color: var(--accent-text); }
#secret-rule-tooltip, body.in-play #room-toolbar #room-expiry {
  background: #1a2b23;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 8px 24px #03090670;
}
.secret-rule-button, body.in-play #room-toolbar #room-expiry-button {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Dice presentation follows the same palette, with outcome colors retained. */
#d20-overlay { background: #06100bc7; backdrop-filter: none; }
.d20-window {
  background: radial-gradient(ellipse at 50% 35%, #263a2e, #111e19 75%);
  border-color: var(--accent);
  box-shadow: 0 22px 72px #030906aa;
  color: var(--text);
}
.d20-window::before, .d20-window::after, .d20-eyebrow { color: var(--accent-text); }
#d20-actor, #d20-formula { color: #bac0af; }
#d20-result { color: #ddc48d; }
.d20-line { background: linear-gradient(90deg, transparent, var(--accent), transparent); }
#d20-meter { background: var(--accent-text); }
#d20-overlay.success #d20-result { color: #a3c6ad; }
#d20-overlay.failure #d20-result { color: #d49a9c; }

@media (max-width: 860px) {
  body.in-play .mobile-game-head {
    background: linear-gradient(90deg, #1c2d26, #13201b);
    border-bottom-color: #a88b575c;
  }
  .mobile-game-eyebrow, #mobile-round { color: var(--accent-text); }
  #mobile-room-name { color: var(--text); }
  #mobile-turn { color: #b6c1ad; }
  body.in-play #game-screen .hero-card {
    background: linear-gradient(155deg, #20342ae8, #13201bf2);
    border-color: #a88b5752;
  }
  body.in-play #game-screen .hero-card.me {
    background: linear-gradient(155deg, #2a3c2df0, #1b2d22f7);
    border-color: #c5a66b99;
  }
  body.in-play #game-screen .mobile-chronicle-strip {
    background: #1c2d26f2;
    border-color: #a88b5752;
  }
  .mobile-chronicle-strip > :first-child,
  .mobile-chronicle-strip strong { color: var(--accent-text); }
  #mobile-chronicle-text { color: #c4cbbb; }
  body.in-play #game-screen #action-form { background: #0e1613f7; }
  body.in-play #game-screen #ready-button,
  body.in-play #game-screen[data-mobile-view="chat"] #chat-form button {
    background: var(--accent);
    color: #0e1613;
  }
  body.in-play #game-screen .dock-line .secret-action {
    background: #1c2d26;
    border-color: #a88b575e;
  }
  body.in-play #game-screen .dock-line .secret-action-icon { color: var(--accent-text); }
  body.in-play #game-screen .dock-line .secret-action input { accent-color: var(--accent); }
  body.in-play #game-screen .mobile-tabs {
    background: #13201bfa;
    border-top-color: #a88b575c;
    box-shadow: 0 -6px 18px #03090655;
  }
  body.in-play #game-screen .mobile-tabs button { color: #b5bcae; }
  body.in-play #game-screen .mobile-tabs button.active {
    border-top-color: var(--accent-text);
    color: #e0c792;
  }
  #mobile-chat-badge { background: var(--danger); color: #0e1613; }
  body.in-play #profile-modal:not([hidden]) { background: var(--bg); }
  body.in-play #profile-card .attribute-row,
  body.in-play #profile-card .derived-row {
    background: #1c2d26;
    border-color: #a88b5740;
  }
  body.in-play #profile-card .attribute-description strong,
  body.in-play #profile-card .derived-description strong { color: var(--text); }
  body.in-play #profile-card .attribute-description small,
  body.in-play #profile-card .derived-description small { color: var(--muted); }
  body.in-play #profile-card .attribute-value,
  body.in-play #profile-card .derived-value { color: var(--accent-text); }
  body.in-play #profile-card .attribute-upgrade { border-color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  button, input, select, textarea { transition: none; }
}
