/* FallAbyss — one graphic style for every page.
   Panels use the approved black-steel and gold frame (assets/ui/panel-metal.webp);
   the background is a dark abyss with slowly drifting mists. Loaded last on every page. */
:root {
  --bg: #07060b; --panel: #17151d; --panel2: #201d27; --line: #4a4654; --ink: #ece4d4; --muted: #a9a2b3;
  --stone-hi: #8f8a99; --stone: #55515f; --stone-lo: #2a2730; --abyss-violet: 120, 50, 200; --abyss-red: 170, 30, 40;
  --frame: url('../assets/ui/panel-metal.webp');
}

/* ---------- the abyss (screen only, never printed) ---------- */
@media screen {
  html { background: #050308; }
  body, body.table { background: transparent; }
  body.table[data-board-background="ember"] { --mist-hue: 76deg; --abyss-violet: 171, 70, 36; }
  body.table[data-board-background="tide"] { --mist-hue: -73deg; --abyss-violet: 39, 119, 154; }
  body.table[data-board-background="moss"] { --mist-hue: -138deg; --abyss-violet: 75, 126, 64; }
  body.table[data-board-background]:not([data-board-background="abyss"])::before { filter: hue-rotate(var(--mist-hue)); }
  body::before, body::after { content: ''; position: fixed; pointer-events: none; z-index: -1; }
  /* Drifting mists: two noise layers (violet and crimson) that turn and slide very slowly */
  body::before {
    inset: -60%;
    background:
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='700' height='700'><filter id='n' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.0032' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .30  0 0 0 0 .09  0 0 0 0 .52  1.7 0 0 0 -.78'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='900'><filter id='n' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.0024' numOctaves='3' seed='21' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .04  0 0 0 0 .08  0 1.8 0 0 -.95'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
      radial-gradient(circle at 50% 50%, rgba(var(--abyss-violet), .22), transparent 30%),
      #050308;
    opacity: .8;
    animation: abyss-drift 140s ease-in-out infinite alternate;
    will-change: transform;
  }
  /* Depth: the center glows faintly from below, the edges fall into black; a slow breathing glow */
  body::after {
    inset: 0;
    background:
      radial-gradient(ellipse 55% 45% at 50% 55%, rgba(var(--abyss-violet), .16), transparent 70%),
      radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(0,0,0,.55) 75%, rgba(0,0,0,.92) 100%);
    animation: abyss-breathe 18s ease-in-out infinite;
  }
  @keyframes abyss-drift {
    0%   { transform: rotate(0deg) translate(0, 0) scale(1); }
    50%  { transform: rotate(9deg) translate(3%, -2%) scale(1.06); }
    100% { transform: rotate(-6deg) translate(-3%, 2%) scale(1.02); }
  }
  @keyframes abyss-breathe { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { body::before, body::after { animation: none; } }
  /* Touch devices avoid the oversized, continuously filtered SVG noise surface.
     The same palette stays visible without rasterizing 4.84 viewport surfaces. */
  @media (pointer:coarse), (max-width:800px), (prefers-reduced-motion:reduce) {
    body::before { inset:0; background:radial-gradient(ellipse at 70% 20%,rgba(var(--abyss-violet),.18),transparent 65%),#050308; animation:none;will-change:auto;transform:none;filter:none!important; }
    body::after { animation:none; }
    .promptbox { animation:promptin .25s ease-out!important; }
    /* Flight remains marked by its icon; idle bobbing is purely decorative. */
    .unit.flyer { animation:none!important; }
  }
}

/* ---------- current frame shared by every panel ---------- */
.promptbox, .modal, .menu, #log.tlog, .tbanner, .toast, .hintbar, .banner,
.side-block, .gen .panel, .pbox, .tile, .rules, .modal.lobby .lobcols > div {
  border: 13px solid transparent !important;
  border-image: var(--frame) 76 stretch !important;
  border-radius: 0 !important;
  background: linear-gradient(170deg, rgba(34,31,42,.95), rgba(14,12,19,.96)) padding-box !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.75), 0 0 40px rgba(var(--abyss-violet), .12) !important;
}
.tbanner, .toast, .hintbar, .banner, .menu, .modal.lobby .lobcols > div { border-width: 10px !important; }
.promptbox { animation: promptin .25s ease-out, promptglow 1.6s ease-in-out infinite !important; }
@keyframes promptglow { 0%, 100% { box-shadow: 0 10px 30px rgba(0,0,0,.75), 0 0 18px rgba(255,210,90,.45); } 50% { box-shadow: 0 10px 30px rgba(0,0,0,.75), 0 0 6px rgba(255,210,90,.15); } }
.side-block { padding: 6px 10px; gap: 7px !important; }
@media (max-height: 820px) {
  .side-block .deck { width: 70px; }
  .side-block .dice:not(.small) .d20 { width: 46px; height: 51px; } .side-block .dice:not(.small) .d20 b { font-size: 18px; }
  .side-block .nextbig { padding: 9px 12px; font-size: 16px; }
}
.side-block:not(.you) { min-width: 200px; }
.menu a:hover { background: rgba(143,138,153,.18); }

/* ---------- top bar: current black-steel palette ---------- */
.topbar {
  background: linear-gradient(110deg,#332a39,#111017 45%,#2a2231) !important;
  border-bottom: 2px solid #1a1820 !important; box-shadow: 0 4px 16px rgba(0,0,0,.8);
}
.phasebar .chip.future { color: #cfc8d8; } .phasebar .chip.past { color: #7d778a; } .phasebar .sep { color: #6c6678; }
.phasebar .chip.current { border: 1px solid #ffe7a0; }

/* ---------- buttons: carved stone, gold when it is the thing to press ---------- */
button {
  background: linear-gradient(#57535f, #34313b 55%, #2a2730) !important; color: var(--ink);
  border: 1px solid #8f8a99 !important; border-radius: 4px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 -2px 0 rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.6);
  text-shadow: 0 1px 2px #000;
}
button:hover:not(:disabled) { border-color: var(--gold) !important; background: linear-gradient(#66616f, #3d3946 55%, #302c37) !important; }
button.primary {
  background: linear-gradient(#c99a3e, #8a6020 60%, #6e4a17) !important; border-color: #ffd98a !important; color: #fff8e6;
}
button.primary:hover:not(:disabled) { background: linear-gradient(#ddb052, #9c6e26 60%, #7d5519) !important; }
button.danger { background: linear-gradient(#8c3a40, #5a1f28) !important; }
.promptbox .pbtns button.toggle { background: linear-gradient(#34313b, #222029) !important; }
.promptbox .pbtns button.toggle.on { background: linear-gradient(#7a5a1c, #4f3a12) !important; border-color: #ffd25a !important; }
#fights .fight, #fights .fight:hover:not(:disabled) {
  background: radial-gradient(circle, rgba(255,214,90,.55), rgba(255,140,40,.15) 60%, transparent 72%) !important;
  border: 0 !important; border-radius: 50% !important; box-shadow: none; text-shadow: none;
}
input, select, textarea { background: #0d0c12; border-color: var(--line); }

/* ---------- game table: the bridge hangs over the abyss ---------- */
.felt { background: transparent !important; box-shadow: none !important; }
.tboard {
  border-radius: 2px;
  box-shadow: 0 0 0 3px #1a1820, 0 0 0 5px #55515f, 0 0 70px 12px rgba(var(--abyss-violet), .28), 0 40px 80px rgba(0,0,0,.95) !important;
}
.boardwrap::before, .boardwrap::after { background: linear-gradient(90deg, transparent, rgba(5,3,8,.55)); }
.deck .count, .foehand .cnt { background: #17151d; border-color: #8f8a99; }
.inspector .empty { border-color: rgba(143,138,153,.35); background: rgba(14,12,19,.55); }
.inspector .big, .hcard, .unit, .deck { border-radius: 4px; }
.costtip { background: rgba(14,12,19,.96); border-color: #8f8a99; }
.tlog, .log { background: rgba(10,9,14,.85); border-color: var(--line); }

/* ---------- other pages ---------- */
.side { background: rgba(14,12,19,.82); }
.handbar { background: rgba(8,7,12,.88); }
.chip { background: #2a2730; } .chip.on { background: #6b4f22; }
.tile { color: var(--ink); transition: transform .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0,0,0,.8), 0 0 30px rgba(var(--abyss-violet), .35) !important; }
.rules { padding: 18px 24px !important; }

@media print { body::before, body::after { display: none; } }
