/* Neutral scene theme. Keep gameplay/element/player colors in styles.css intact.
   Centralized tokens are ready for a future Settings theme picker. */
:root {
  --ink: #f0f0f0;
  --muted: #b0b0b0;
  --edge: #505050;
  --tile: #292929;
  --tile-dark: #242424;
  --scene-center: #303030;
  --scene-edge: #111111;
  --ui-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ui-text: #eeeeee;
  --ui-muted: #b5b5b5;
  --ui-border: #ffffff26;
  --ui-glass: linear-gradient(145deg, #393939c9, #1c1c1ce8);
  --ui-solid: linear-gradient(145deg, #343434fa, #1b1b1bfc);
  --ui-button: linear-gradient(155deg, #ffffff26, #ffffff0d);
  --ui-button-hover: linear-gradient(155deg, #ffffff38, #ffffff19);
  --ui-focus: #e2e2e2;
}

body { background: radial-gradient(ellipse at 50% 40%, var(--scene-center), #1c1c1c 58%, var(--scene-edge)); }

/* No shared background behind either hand; only actual UI panels get glass. */
.phase-tracker, .action-log, .player-summary, .market-panel {
  background: var(--ui-glass);
  border-color: var(--ui-border);
  color: var(--ui-text);
  box-shadow: inset 0 1px 0 #ffffff0a, 0 10px 28px #0004;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.hand-overflow, .market-dialog, .pile-inspector, .token-exchange,
.card-inspector, .ability-choice-panel, .dev-card-tools[open] {
  background: var(--ui-solid);
  border-color: var(--ui-border);
  color: var(--ui-text);
}
.hand-overflow::backdrop, .market-dialog::backdrop, .pile-inspector::backdrop { background: #0009; }

.tile-revealer { border-color: var(--ui-border); background: #ffffff04; }
.tile-revealer legend, .tile-revealer small { color: var(--ui-muted); }
.tile-revealer span { color: var(--ui-muted); }
.tile-revealer input:checked + span { background: var(--ui-button); border-color: #ffffff4a; color: #fff; box-shadow: inset 0 1px 0 #ffffff12; }
.tile-revealer input:focus-visible + span { outline-color: var(--ui-focus); }
.tile-revealer label:hover span { color: #fff; }

/* Target controls explicitly: never recolor card artwork or board-piece buttons. */
:is(.header-controls button, #next-phase, #action-log-latest, #exchange-toggle,
    .token-exchange button, .investment-tier, .spell-actions button,
    .ability-choice-panel button, dialog:not(.menu-dialog) button:not(.has-card-art), .inspector-heading button) {
  background: var(--ui-button);
  color: var(--ui-text);
  border: 1px solid #ffffff30;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 #ffffff16, 0 3px 8px #0002;
  filter: none;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.header-controls button { font-weight: 600; }
:is(.header-controls button, #next-phase, #action-log-latest, #exchange-toggle,
    .token-exchange button, .investment-tier, .spell-actions button,
    .ability-choice-panel button, dialog:not(.menu-dialog) button:not(.has-card-art), .inspector-heading button):not(:disabled):hover {
  background: var(--ui-button-hover);
  border-color: #ffffff60;
  box-shadow: inset 0 1px 0 #ffffff24, 0 4px 12px #0003;
  filter: none;
}
:is(.header-controls button, #next-phase, #action-log-latest, #exchange-toggle,
    .token-exchange button, .investment-tier, .spell-actions button,
    .ability-choice-panel button, dialog:not(.menu-dialog) button:not(.has-card-art), .inspector-heading button):focus-visible {
  outline: 2px solid var(--ui-focus); outline-offset: 3px;
}
:is(.header-controls button, #next-phase, .investment-tier, .token-exchange button, dialog:not(.menu-dialog) button:not(.has-card-art)):disabled {
  opacity: .38; box-shadow: none; filter: none;
}
:is(#next-phase, .investment-tier).achieved { background: #ffffff38; border-color: #ffffffa0; color: #fff; opacity: 1; box-shadow: inset 0 1px 0 #ffffff30; }
.investment-tier { display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.investment-tier img { width: 16px; height: 16px; object-fit: contain; }
.resource-redeem { background: #eeeeee; color: #171717; border: 1px solid #ffffff80; border-radius: 10px; box-shadow: inset 0 1px 0 #fff3; }
.resource-redeem:not(:disabled):hover { background: #fff; color: #111; }
.resource-redeem:disabled { opacity: .38; }
.tile.enemy-preview { box-shadow: inset 0 0 0 2px #b9d5ef; }
.tile.enemy-preview-selected { outline: 2px solid #e2efff; outline-offset: -3px; }
:is(#next-phase, .investment-tier).investment-ready, #exchange-toggle.trade-ready { border-color: #ffffff70; color: #fff; }
#exchange-confirm { color: var(--ui-text); border-color: var(--ui-border); }
#exchange-confirm:not(:disabled) { background: #eeeeee; color: #171717; border-color: #ffffff80; }
#exchange-confirm:not(:disabled):hover { background: #fff; color: #111; }
#exchange-toggle.trade-ready { text-shadow: none; box-shadow: inset 0 1px 0 #ffffff16, 0 3px 8px #0002; }
:is(#next-phase, .spell-actions button, .hand-overflow .overflow-choice)[aria-pressed='true']:not(.has-card-art) {
  background: #ffffff26; border-color: #ffffff90; box-shadow: inset 0 0 0 1px #ffffff30;
}

#phase-player, .phase-list li, .phase-list .is-complete { color: var(--ui-muted); }
.phase-list .is-current { background: #ffffff0e; border-color: #ffffff3b; color: #fff; }
.phase-list .is-current img { filter: drop-shadow(0 0 5px #ffffff50); }
/* The Draw artwork has wider transparent margins than the other phase icons. */
.phase-list li:first-child img { transform: scale(1.28); }
.phase-icon-pair { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex-shrink: 0; }
.phase-icon-pair img { flex-shrink: 0; }
.phase-icon-separator { font-size: 16px; line-height: 1; font-weight: 400; opacity: .45; }
.is-current .phase-icon-separator { opacity: 1; }
@media (max-height: 650px) and (min-width: 701px) {
  .phase-list li:last-child { grid-column: 1 / -1; }
}

/* Compact charcoal inspector, with a clear hierarchy and softly separated groups. */
.card-inspector { width: 340px; padding: 18px; border-radius: 18px; box-shadow: 0 20px 60px #0009, inset 0 1px 0 #ffffff10; scrollbar-width: thin; scrollbar-color: #666 transparent; }
.inspector-heading { padding-bottom: 12px; border-bottom: 1px solid var(--ui-border); margin-bottom: 16px; }
.inspector-heading h2 { font-size: 17px; line-height: 1.3; }
.inspector-heading h2 > span { text-shadow: 0 0 9px color-mix(in srgb, var(--card-element-glow) 45%, transparent); }
.inspector-heading .inspector-element { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--card-element-glow) 50%, transparent)); }
.inspector-heading button { flex-shrink: 0; }
.inspector-hero { grid-template-columns: 116px minmax(0, 1fr); gap: 16px; }
.inspector-hero > img, .inspector-hero .inspector-card-art { width: 116px; max-height: none; }
.inspector-hero > img { max-height: 160px; }
.inspector-hero .inspector-card-art img { width: 100%; height: 100%; max-height: none; }
.inspector-facts { min-width: 0; }
.inspector-eyebrow { color: var(--ui-muted); font-size: 10px; letter-spacing: .06em; }
.inspector-stat-label { display: block; margin-top: 10px; color: var(--ui-muted); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.inspector-stat { margin-top: 1px; font-size: 30px; }
.inspector-ability, .inspector-location { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--ui-border); }
.card-inspector .inspector-ability h3, .card-inspector .inspector-location h3 { margin-top: 0; color: var(--ui-muted); font-size: 10px; }
.inspector-ability p { line-height: 1.65; }
.inspector-movement { padding: 12px; gap: 16px; border: 1px solid #ffffff12; border-radius: 12px; background: #ffffff05; }
.inspector-readiness { color: var(--ui-muted); font-size: 11px; line-height: 1.5; }
.card-inspector .card-traits:empty, .card-inspector .spell-actions:empty { display: none; }
.card-inspector .card-traits > span { padding: 3px 5px; border-radius: 6px; background: #ffffff08; color: var(--ui-text); }
.inspector-position-tile, .map-label { color: var(--ui-muted); }
.map-cell { border-color: #ffffff1c; background: #ffffff05; }
@media (max-width: 700px) { .card-inspector { width: 300px; padding: 14px; } }
.action-log h2, .log-phase, #summary-player, .summary-tokens strong, .summary-strongholds strong { color: var(--ui-text); }
.action-log header > span { color: #c7c7c7; }
.log-entry { color: #d0d0d0; border-bottom-color: #ffffff0b; }
.log-phase { background: #ffffff05; border-color: var(--ui-border); }
#action-log-list, .pile-cards { scrollbar-color: #606060 transparent; }
#action-log-list:focus-visible { outline-color: var(--ui-focus); }
#summary-player option, .dev-card-tools select, .dark-choice-content input { background: #292929; color: var(--ui-text); border-color: #ffffff35; }
:is(#exchange-hint, .exchange-options small, #market-description, #investment-description,
    #pile-description, .pile-eyebrow, .pile-empty, .pile-card p, .inspector-muted,
    .overflow-eyebrow, #overflow-label, #overflow-selection, .overflow-footnote) { color: var(--ui-muted); }

/* Neutral tabletop furniture; revealed element artwork and scenery stay original. */
.board-frame, .board { position: relative; }
/* Short, softly lit center tick + edge arrows mark the four 8 × 8 quadrants. */
.board::before, .board::after {
  content: ''; position: absolute; z-index: 3; pointer-events: none;
  border-radius: 1px; filter: drop-shadow(0 1px 1px #000c);
}
.board::before { left: calc(50% - .5px); top: calc(50% - 13px); width: 1px; height: 26px; background: linear-gradient(to bottom, transparent, #f4f4f4b3 35%, #f4f4f4b3 65%, transparent); }
.board::after { top: calc(50% - .5px); left: calc(50% - 13px); height: 1px; width: 26px; background: linear-gradient(to right, transparent, #f4f4f4b3 35%, #f4f4f4b3 65%, transparent); }
.quadrant-edge { position: absolute; width: 7px; height: 5px; background: #e9e9e99c; pointer-events: none; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.quadrant-edge-top { left: calc(50% - 3.5px); top: 2px; }
.quadrant-edge-bottom { left: calc(50% - 3.5px); bottom: 2px; transform: rotate(180deg); }
.quadrant-edge-left { top: calc(50% - 2.5px); left: 1px; transform: rotate(-90deg); }
.quadrant-edge-right { top: calc(50% - 2.5px); right: 1px; transform: rotate(90deg); }
.playmat { background: linear-gradient(135deg, #3c3c3c66, #24242455); border-color: #ffffff23; }
.board-frame { background: linear-gradient(135deg, #85858590, #36363690); border-color: #bcbcbc8c; box-shadow: 0 6px 0 #242424, 0 12px 22px #0006; }
.board { background: #33333333; border-color: #c0c0c075; }
.board .tile.hidden { background: #2626266b; border-color: #cccccc30; }
.board .tile.hidden:nth-child(even) { background: #40404052; }
.board .tile.hidden::after { border-color: #ffffff18; }
.market-card.market-empty { background: #ffffff05; border-color: #ffffff30; color: #d0d0d0; }
.market-card.market-empty:hover, .market-card.market-empty:focus-visible { background: #ffffff12; box-shadow: inset 0 0 14px #ffffff18; }

/* Root-level choices sit above fixed HUD panels; board targeting stays clickable.
   Private choices still use the native dialog top layer. */
.ability-choice-panel, dialog[data-choice-mode='board'] {
  position: fixed; z-index: 200; inset: 112px auto auto 12px; margin: 0;
  transform: none; width: min(310px, calc(100vw - 24px));
  max-height: calc(100dvh - 232px); padding: 16px;
  overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--ui-border); border-radius: 12px;
  background: var(--ui-solid); color: var(--ui-text); box-shadow: 0 10px 32px #0007;
}
:is(#death-search, #light-promotion, #earth-choice, #dark-choice, #air-choice, #fire-choice, #light-choice, #water-choice) {
  max-height: min(76dvh, 700px); overflow: auto; overscroll-behavior: contain;
  scrollbar-color: #777 transparent;
}
dialog[data-choice-mode='board'] { max-height: calc(100dvh - 232px); }
:is(#ability-choice-content, .dark-choice-content, #earth-choice-cards, #death-search-cards, #light-promotion-cards) {
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 10px;
}
:is(#ability-choice-content, .dark-choice-content, #earth-choice-cards, #death-search-cards, #light-promotion-cards) > :is(p, strong, label, details, .choice-step) { flex: 0 0 100%; margin: 0; }
:is(#ability-choice-content, .dark-choice-content) > button:not(.light-card-choice):not(.water-card-choice) { flex: 1 0 100%; margin: 0; min-height: 36px; white-space: normal; }
:is(#ability-choice-content, .dark-choice-content, #earth-choice-cards, #death-search-cards, #light-promotion-cards) > :is(.light-card-choice, .water-card-choice, .has-card-art) {
  display: flex; flex: 0 1 128px; flex-direction: column; align-items: center; gap: 6px;
  width: 128px; min-width: 0; height: auto; margin: 0; padding: 8px;
  font-size: 12px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere;
}
:is(.light-card-choice, .water-card-choice, #earth-choice-cards .has-card-art, #death-search-cards .has-card-art, #light-promotion-cards .has-card-art, #fire-choice-content .light-card-choice, #light-choice-content .light-card-choice, #water-choice-content .water-card-choice) .card-art-frame {
  width: 96px; height: auto; aspect-ratio: 11 / 15; flex: none;
}
/* Centered spell choices share the available width; board targeting uses its side panel. */
:is(#death-search, #light-promotion, #earth-choice, #dark-choice, #air-choice, #fire-choice, #light-choice, #water-choice)[data-choice-mode='private'] {
  --choice-art-width: clamp(56px, 14dvh, 110px);
  box-sizing: border-box;
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  padding: clamp(12px, 2.4dvh, 24px);
  gap: 8px;
}
dialog[data-choice-mode='private'] > :is(#earth-choice-cards, #death-search-cards, #light-promotion-cards, .dark-choice-content) {
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  align-content: flex-start;
  gap: 8px;
  padding: 4px;
}
dialog[data-choice-mode='private'] :is(#earth-choice-cards, #death-search-cards, #light-promotion-cards, .dark-choice-content) > button:has(.card-art-frame) {
  box-sizing: border-box;
  display: flex;
  flex: 0 1 calc(var(--choice-art-width) + 16px);
  flex-direction: column;
  align-items: center;
  width: auto;
  min-width: 0;
  height: auto;
  aspect-ratio: auto;
  padding: 6px;
  margin: 0;
  gap: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
}
dialog[data-choice-mode='private'] :is(#earth-choice-cards, #death-search-cards, #light-promotion-cards, .dark-choice-content) .card-art-frame {
  flex: none;
  width: var(--choice-art-width);
  max-width: 100%;
  height: auto;
  aspect-ratio: 11 / 15;
}
dialog[data-choice-mode='private'] #earth-choice-cards > button:not(:has(.card-art-frame)) {
  aspect-ratio: auto;
  min-height: 36px;
  padding: 8px 12px;
}
.choice-step { font-size: 11px; font-weight: 700; letter-spacing: .035em; color: #ededed; padding-bottom: 10px; border-bottom: 1px solid var(--ui-border); }
.choice-target-list { font-size: 12px; border-top: 1px solid var(--ui-border); padding-top: 10px; }
.choice-target-list summary { cursor: url('assets/elven-cursor.svg') 3 2, pointer; padding: 6px 0; color: var(--ui-muted); }
.choice-target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 180px; overflow-y: auto; margin-top: 8px; }
.choice-target-grid button { min-height: 32px; margin: 0; padding: 5px; font-size: 11px; }
:is(.ability-choice-panel, .death-search) button[aria-pressed='true'] { outline: 2px solid #ededed; outline-offset: -2px; background: #ffffff25; }
:is(.ability-choice-panel, .death-search) button:disabled { opacity: .55; cursor: not-allowed; }
:is(.ability-choice-panel, .death-search) :is(button, summary):focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.board .tile.spell-target { outline: 1px dashed #f5f5f5; outline-offset: -3px; box-shadow: inset 0 0 7px #ffffff60; }
.board .tile.ability-target-selected { outline: 2px solid #fff; outline-offset: -3px; }
.playmat .mat-slot.spell-slot-target { outline: 2px dashed #f0f0f0; outline-offset: 2px; background: #ffffff18; }
@media (max-width: 700px), (max-height: 620px) {
  .ability-choice-panel, dialog[data-choice-mode='board'] { inset: auto auto 12px 12px; width: min(310px, calc(100vw - 24px)); max-height: 36dvh; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.header-controls button, #next-phase, #action-log-latest, #exchange-toggle,
      .token-exchange button, .investment-tier, .spell-actions button,
      .ability-choice-panel button, dialog:not(.menu-dialog) button:not(.has-card-art), .inspector-heading button) { transition: none; }
}

/* One interface typeface across local and Friendly play; card artwork keeps its typography. */
:is(.header-controls, .phase-tracker, .action-log, .player-summary, .card-inspector,
    .ability-choice-panel, .token-exchange, .hand-overflow, .market-dialog, .pile-inspector) {
  font-family: var(--ui-font);
}
:is(.header-controls, .phase-tracker, .action-log, .player-summary, .card-inspector,
    .ability-choice-panel, .token-exchange, .hand-overflow, .market-dialog, .pile-inspector)
    :is(button, input, select, textarea, h2, h3, .summary-name) { font-family: var(--ui-font); }

/* A quiet cue while a card is waiting for the player's decision. */
.ability-choice-panel:not([hidden]), dialog[data-choice-mode][open] {
  border-color: #bca4dc;
  box-shadow: 0 10px 32px #0007, 0 0 12px #b895e847, inset 0 0 8px #b895e814;
  animation: spell-choice-attention 3s ease-in-out infinite;
}
@keyframes spell-choice-attention {
  0%, 100% { box-shadow: 0 10px 32px #0007, 0 0 10px #b895e838, inset 0 0 6px #b895e810; }
  50% { box-shadow: 0 10px 32px #0007, 0 0 19px #b895e86b, inset 0 0 9px #b895e81c; }
}
@media (prefers-reduced-motion: reduce) {
  .ability-choice-panel:not([hidden]), dialog[data-choice-mode][open] { animation: none; }
}
