:root {
  --bg: #0a0e1a;
  --panel: #141b2e;
  --panel2: #1b2438;
  --ink: #e8ecf6;
  --dim: #8b97b4;
  --storm: #6cd3ff;
  --storm-deep: #2a7fb8;
  --might: #ff5f6d;
  --gold: #ffd166;
  --good: #4ade80;
  --card: #1d2740;
  /* The chisel: one token drives every silhouette. Cut 45° corners, not curves. */
  --bev: 12px;
  /* The anvil: plates are RAISED. Light comes from the top-left, so the silhouette gets a
     lit rim up-left, a dark rim down-right, and a grounding shadow beneath. box-shadow dies
     on clipped shapes — stacked drop-shadows follow the cut octagon instead. */
  --edge-lit: #5c6f9a;
  --edge-dark: #05080f;
  --raise: drop-shadow(-1px -1px 0 var(--edge-lit)) drop-shadow(1px 1px 0 var(--edge-dark))
           drop-shadow(0 4px 8px #00000059);
  --raise-lg: drop-shadow(-1px -1px 0 var(--edge-lit)) drop-shadow(1.5px 1.5px 0 var(--edge-dark))
              drop-shadow(0 3px 6px #00000055) drop-shadow(0 12px 24px #00000066);
}
* { box-sizing: border-box; }
/* The UA's [hidden]{display:none} loses to ANY author rule setting `display` (like #overlay's
   flex below), which silently un-hides things the JS thinks are hidden. This guard is load-
   bearing: without it the result modal covers the page from first load and clicks die on it. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #17243f 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 110%, #16122b 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { letter-spacing: .18em; margin: 0; }
h1 span { color: var(--storm); }
.tag { color: var(--dim); margin: 4px 0 0; letter-spacing: .03em; }

header { text-align: center; padding: 26px 16px 6px; }
main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 40px; }
h2 { font-weight: 650; letter-spacing: .04em; }
button {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid #33406a; background: #223052; color: var(--ink);
  padding: 9px 15px; transition: transform .05s, filter .15s, background .15s;
  filter: var(--raise); box-shadow: inset 0 1px 0 #ffffff14;
}
button:hover:not(:disabled) { filter: var(--raise) brightness(1.15); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #2c86c4, #216da3); border-color: #3f9ad6; }
button.ghost { background: transparent; color: var(--dim); filter: none; box-shadow: none; }
button.ghost:hover:not(:disabled) { filter: brightness(1.3); transform: none; }

/* ---- the chisel: octagonal clip-path silhouettes (A) on every surface ----
   clip-path cuts the border on the diagonals — on this palette the fill-vs-sky contrast
   carries the edge, and every glow that must survive is a drop-shadow (outside, follows
   the cut silhouette) or an inset shadow (inside, never clipped away). */
button, .god, .card, .npc-card, #rules, .log, .result-card, #toast, .rc-face, .shelf, .bar {
  clip-path: polygon(var(--bev) 0, calc(100% - var(--bev)) 0,
    100% var(--bev), 100% calc(100% - var(--bev)),
    calc(100% - var(--bev)) 100%, var(--bev) 100%,
    0 calc(100% - var(--bev)), 0 var(--bev));
}
button { --bev: 7px; }
button.relic { --bev: 8px; }
.result-card { --bev: 16px; }
#toast { --bev: 8px; }
.bar { --bev: 5px; box-shadow: inset 0 1px 3px #000000a6; }   /* the track sinks; the fill glows in it */
.god, .npc-card, #rules, .log, .result-card, .shelf {
  filter: var(--raise-lg); box-shadow: inset 0 1px 0 #ffffff12;
}
/* the focus ring used to live outside the box; clip-path would eat it */
button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px #8fd8ff; }

/* ---- lobby ---- */
.npc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; }
.npc-card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid #2b3a5c; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.npc-card .rank { color: var(--gold); font-size: 12px; letter-spacing: .22em; }
.npc-card .nm { font-size: 19px; font-weight: 700; }
.npc-card .blurb { color: var(--dim); font-size: 13px; flex: 1; min-height: 54px; }
.npc-card button { margin-top: 4px; }
#rules { margin-top: 22px; background: var(--panel); border: 1px solid #26334f; padding: 12px 18px; }
#rules summary { cursor: pointer; color: var(--storm); font-weight: 600; }
#rules li { margin: 8px 0; }
#rules b { color: var(--gold); }

/* ---- board ---- */
.topline { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.turn { color: var(--storm); font-weight: 700; letter-spacing: .06em; }
.warn { color: var(--might); font-weight: 600; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.topline button { margin-left: auto; }

.arena { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.god {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid #2b3a5c; padding: 14px 16px;
  position: relative;                    /* anchor for the molten seam */
}
/* Forge seam (C): each god's panel is welded to its allegiance — a hot line with a white
   core, glowing down into the plate, instead of a flat painted bar. */
.god::before {
  content: ''; position: absolute; left: 16%; right: 16%; top: 0; height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--storm-deep) 15%, var(--storm) 42%,
    #eaffff 50%, var(--storm) 58%, var(--storm-deep) 85%, transparent);
  box-shadow: 0 1px 10px 1px #6cd3ff55, 0 2px 24px 4px #6cd3ff2b;
}
.god.rival::before {
  background: linear-gradient(90deg, transparent, #b3273a 15%, var(--might) 42%,
    #ffecec 50%, var(--might) 58%, #b3273a 85%, transparent);
  box-shadow: 0 1px 10px 1px #ff5f6d55, 0 2px 24px 4px #ff5f6d2b;
}
.god .who { display: flex; justify-content: space-between; align-items: baseline; }
.god .who .nm { font-weight: 700; font-size: 16px; }
.god .who .last { font-size: 12px; color: var(--dim); }

.bar { height: 16px; background: #0d1424; overflow: hidden; margin: 6px 0; position: relative; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #b3273a, var(--might)); transition: width .35s; }
.bar .lbl { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 1px 2px #000; }

.statrow { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 6px; font-size: 13px; }
.pips { display: inline-flex; gap: 3px; }
.pip { width: 11px; height: 11px; border-radius: 3px; background: #10203a; border: 1px solid #24405f; }
.pip.on { background: radial-gradient(circle at 35% 30%, #bdefff, var(--storm) 60%, var(--storm-deep)); border-color: #9fe4ff; box-shadow: 0 0 6px #3ba7e0aa; }
.chip { background: #0f1830; border: 1px solid #29406e; border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.chip.guard { border-color: #3f7bb0; color: #a8d7ff; }
.chip.charge { border-color: #b0933f; color: var(--gold); }

.cds { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.cd { font-size: 11px; color: #ffd9a0; background: #241a12; border: 1px solid #574022; border-radius: 6px; padding: 1px 6px; }

/* ---- hand ---- */
.hand { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card {
  position: relative; text-align: left; background: linear-gradient(180deg, #24304f, #1a2338);
  border: 1px solid #33456e; padding: 10px 11px 11px; min-height: 108px;
  display: flex; flex-direction: column; gap: 4px;
  filter: var(--raise-lg);
}
.card:hover:not(:disabled) { border-color: var(--storm);
  filter: var(--raise-lg) drop-shadow(0 0 10px #2c86c466) brightness(1.06); }
.card .top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card .cname { font-weight: 700; font-size: 14px; }
.card .cost {
  min-width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px;
  font-size: 12px; font-weight: 800; color: #071322;
  background: radial-gradient(circle at 35% 30%, #cdefff, var(--storm) 65%, var(--storm-deep));
}
.card .cost.free { background: radial-gradient(circle at 35% 30%, #d8ffe6, #57d98b 65%, #2e9e5e); }
.card .txt { color: #c3cee6; font-size: 12px; }
.card .meta { color: #7f8cb0; font-size: 11px; }
.card .cool {
  position: absolute; inset: 0; clip-path: inherit; background: #060b16d0;
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #ffd9a0;
  font-size: 15px; letter-spacing: .04em;
}
.card.no-look { opacity: .8; }
/* the type badge sits on the cut corner — give it its own small bevel to hug the silhouette */
.card .kind { position: absolute; top: 0; right: 0; font-size: 13px; padding: 2px 7px; opacity: .85;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); }
.kind.k-atk { background: #4a1e26; } .kind.k-grd { background: #17354d; }
.kind.k-str { background: #33294d; } .kind.k-heal { background: #16401f; }
.kind.k-trick { background: #10333a; }

/* ---- log ---- */
.log { background: var(--panel); border: 1px solid #26334f; padding: 10px 14px; max-height: 260px; overflow-y: auto; }
.log h3 { margin: 2px 0 8px; font-size: 13px; color: var(--dim); letter-spacing: .1em; }
.log .beat { border-top: 1px dashed #24314f; padding: 7px 0; }
.log .beat:first-of-type { border-top: 0; }
.log .revealed { font-size: 13px; }
.log .revealed b.you { color: var(--storm); }
.log .revealed b.them { color: var(--might); }
.log .evts { color: var(--dim); font-size: 12px; margin-top: 2px; }
.log .empty { color: var(--dim); font-size: 13px; }

/* ---- overlay ---- */
#overlay { position: fixed; inset: 0; background: #05070fd0; display: flex; align-items: center; justify-content: center; }
.result-card { background: linear-gradient(180deg, #1c2740, #121a2c); border: 1px solid #3a4c78; padding: 30px 34px; text-align: center; max-width: 380px; }
.result-card h2 { margin-top: 0; }
.result-card.win h2 { color: var(--gold); }
.result-card.loss h2 { color: var(--might); }
.result-card.draw h2 { color: var(--dim); }
.result-card .row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #4a1e26; border: 1px solid #a4564f; color: #ffd9d5; padding: 10px 18px; }

@media (max-width: 640px) { .arena { grid-template-columns: 1fr; } }

/* ================= presentation layer (fx.js) ================= */

/* Pixi canvases: sky behind everything, effects above the board but click-transparent */
#sky-canvas  { position: fixed; inset: 0; z-index: -2; }
#stage-canvas{ position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#fxdom       { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
#flash       { position: fixed; inset: 0; z-index: 65; pointer-events: none; opacity: 0; background: #fff; }
#reveal      { position: fixed; inset: 0; z-index: 80; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: center; gap: 34px;
  padding-top: 21vh; perspective: 900px; }   /* centre on the arena, not the hand */

/* mute icon */
.topline .icon { margin-left: auto; padding: 6px 10px; }
.topline #leaveBtn { margin-left: 4px; }

/* --- simultaneous card reveal: fly in back-first, flip at the same instant --- */
.rc { width: 128px; height: 182px; position: relative; transform-style: preserve-3d; }
.rc.from-you  { animation: rc-you  .34s cubic-bezier(.2,.7,.3,1) forwards; }
.rc.from-them { animation: rc-them .34s cubic-bezier(.2,.7,.3,1) forwards; }
/* each card flies in from its own god's side: rival panel left, player panel right */
@keyframes rc-you  { from { opacity: 0; transform: translate(46vw, 32vh) rotate(14deg); }
                     to   { opacity: 1; transform: none; } }
@keyframes rc-them { from { opacity: 0; transform: translate(-46vw, -32vh) rotate(-12deg); }
                     to   { opacity: 1; transform: none; } }
.rc-in { position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateY(180deg); transition: transform .46s cubic-bezier(.3,.7,.3,1); }
.rc.faceup .rc-in { transform: rotateY(0deg); }
.rc-face { position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  border: 1px solid #3a4c78; }
.rc-back { transform: rotateY(180deg); font-size: 42px; color: #2f5e8f;
  background: repeating-linear-gradient(135deg, #16223d 0 10px, #1b2a4a 10px 20px); }
.rc-front { background: linear-gradient(180deg, #2a3a63, #151e35); }
.rc-front b { font-size: 17px; text-align: center; padding: 0 10px; letter-spacing: .02em; }
.rc-front i { font-size: 40px; font-style: normal; filter: drop-shadow(0 0 10px currentColor); }

/* --- floating combat numbers --- */
.float-num { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 22px;
  text-shadow: 0 2px 8px #000, 0 0 18px currentColor; animation: floatUp 1.2s ease-out forwards; }
.float-num.good { color: #57d98b; }
.float-num.bad  { color: #ff6b78; }
.float-num.big  { font-size: 34px; }
.float-num.guard-chip   { color: #a8d7ff; font-size: 16px; }
.float-num.storm-float  { font-size: 14px; text-shadow: 0 1px 4px #000; }
.float-num.warn-float   { color: #ffb26b; font-size: 15px; letter-spacing: .1em; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  12%  { opacity: 1; transform: translate(-50%, -55%) scale(1.18); }
  100% { opacity: 0; transform: translate(-50%, -165%) scale(1); }
}

/* --- rising hearts / heal glyphs --- */
.glyph-pop { position: absolute; transform: translate(-50%, -50%); opacity: 0;
  text-shadow: 0 0 12px currentColor; animation: glyphUp 1.4s ease-out forwards; }
@keyframes glyphUp {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.5); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - var(--rise, 90px))) scale(1.25) rotate(8deg); }
}

/* --- impact shake (applied to panels and arena) --- */
.shk-s { --sx: 3px; } .shk-m { --sx: 7px; } .shk-l { --sx: 12px; }
.shk-s, .shk-m, .shk-l { animation: shk .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shk {
  10%, 90% { transform: translate(calc(var(--sx) * -.2), 0); }
  20%, 80% { transform: translate(calc(var(--sx) * .4), 0); }
  30%, 50%, 70% { transform: translate(calc(var(--sx) * -.6), calc(var(--sx) * .2)); }
  40%, 60% { transform: translate(calc(var(--sx) * .6), calc(var(--sx) * -.2)); }
}

/* --- knockout and victory --- */
.god.ko { filter: var(--raise) grayscale(.92) brightness(.55);
  transform: perspective(600px) rotateX(5deg) translateY(10px);
  transition: filter .8s, transform .8s; }
.god.champ { filter: var(--raise-lg) drop-shadow(0 0 16px #ffd16688) drop-shadow(0 0 42px #ffd16644);
  box-shadow: inset 0 0 26px #ffd16622; border-color: #ffd166;
  transition: filter .6s, box-shadow .6s, border-color .6s; }

/* keep the modal above the fx layers */
#overlay { z-index: 95; }

@media (prefers-reduced-motion: reduce) {
  .bar > i, .rc-in { transition: none; }
  .shk-s, .shk-m, .shk-l { animation: none; }
}
@media (max-width: 640px) {
  .rc { width: 96px; height: 138px; }
  #reveal { gap: 16px; }
}

/* ================= the forge (in-duel market) ================= */

.shelf { margin: 10px 0 4px; padding: 10px 12px; border: 1px solid #3a4c7855;
  background: #101a30cc; }
.shelf-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 11px; letter-spacing: .14em; color: #7d94c4; text-transform: uppercase;
  margin-bottom: 8px; }
.shelf-head .rival-relics { letter-spacing: .02em; text-transform: none; color: #ffb26b; }
.shelf .wares { display: flex; gap: 8px; flex-wrap: wrap; }
button.relic { display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 128px; padding: 8px 12px; cursor: pointer;
  border: 1px solid #4a5f93; background: linear-gradient(180deg, #223258, #16223d); color: inherit; }
button.relic .rg { font-size: 17px; filter: drop-shadow(0 0 8px currentColor); }
button.relic .rn { font-weight: 700; font-size: 13px; }
button.relic .rp { color: #ffd166; font-weight: 800; font-size: 13px; }
button.relic .rt { color: #c3cee6; font-size: 12px; line-height: 1.35; }
button.relic .rc2 { color: #7d94c4; font-size: 11px; }
button.relic:hover:not(:disabled) { border-color: #ffd166aa;
  filter: var(--raise) drop-shadow(0 0 9px #ffd16640); }
button.relic.off { opacity: .4; cursor: not-allowed; }
/* the forged marker used an outside outline — clip-path eats those; ring lives inside now */
.card.forged { box-shadow: inset 0 0 0 2px #ffd166aa, inset 0 0 14px #ffd16630; }

/* ---- human duels (PvP) ---- */
.pvp-bar { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.pvp-bar input {
  font: inherit; color: var(--ink); background: #0d1424; border: 1px solid #33406a;
  padding: 9px 14px; --bev: 7px;
  clip-path: polygon(var(--bev) 0, calc(100% - var(--bev)) 0, 100% var(--bev),
    100% calc(100% - var(--bev)), calc(100% - var(--bev)) 100%, var(--bev) 100%,
    0 calc(100% - var(--bev)), 0 var(--bev));
}
.pvp-bar input:focus { outline: none; border-color: var(--storm); }
.pvp-empty { color: var(--dim); font-size: 13px; padding: 10px 2px; grid-column: 1 / -1; }
.pend { color: var(--storm); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  animation: pulse 1.6s infinite; }
