/* The battle board (battle/board.js): art-only tiles, splash health. */
.screen.battle { padding: 4px 0 12px; gap: 8px; }
.battle-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.battle-head h2 { font: 900 clamp(17px, 5vw, 22px)/1.1 var(--display); text-align: center; outline: none; }

.board {
  --tw: clamp(64px, min(calc((100dvh - 330px - var(--sab)) / 3.9), calc((min(100vw, 30rem) - 32px - 6px - 16px - 16px) / 3)), 112px);
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px; border: 3px solid var(--ink); border-radius: 22px; background: #f2e6d9;
}
/* With the sheet up there's room to scroll the board clear of it. */
.board.sheeted { margin-bottom: 170px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 4px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; }
.banner .who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wname { font: 800 22px/1 var(--name); overflow: hidden; padding-bottom: .25em; margin-bottom: -.1em; /* room for the underscore, which hangs below the baseline */ text-overflow: ellipsis; white-space: nowrap; }
.wsub { font: 500 12px/1 var(--mono); color: var(--muted); }
.pips { display: flex; gap: 3px; flex-wrap: wrap; }
.bighp { flex: none; width: 60px; height: 60px; }
.bighp svg { width: 100%; height: 100%; display: block; }

.row { display: grid; grid-template-columns: repeat(3, var(--tw)); justify-content: space-between; gap: 8px; }
.row.sweep .tile { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.hand { display: flex; gap: 10px; min-height: calc(var(--tw) * 0.7 * 1.4 + 6px); padding: 6px 14px 14px 4px; overflow-x: auto; }
.hand .empty { align-self: center; font: 600 14px/1.3 var(--body); color: var(--muted); }

.tile {
  position: relative; display: block; flex: none; padding: 0;
  width: var(--tw); aspect-ratio: 5 / 7;
  border: 0; border-radius: 10px; background: #fff; cursor: pointer;
  box-shadow: 0 0 0 3px var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.tile .pic { display: block; width: 100%; height: 100%; border-radius: 10px; }
.tile.inhand { width: calc(var(--tw) * 0.7); }
.tile.avatar { --tw: 68px; width: 68px; }
.tile .stamp { position: absolute; left: 5px; top: 5px; width: 22px; height: 22px; }
.tile .stamp svg { width: 22px; height: 22px; display: block; }
.tile .cost { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 3px; padding: 4px 5px; background: var(--ink); border-radius: 6px; }
.tile .hpb { position: absolute; right: -9px; bottom: -9px; width: 40px; height: 40px; pointer-events: none; }
.tile .hpb svg { width: 100%; height: 100%; display: block; }
.tile.inhand .hpb { width: 32px; height: 32px; right: -7px; bottom: -7px; }
.tile.avatar .stamp, .tile.avatar .cost { display: none; }
.tile .brace { position: absolute; right: 4px; top: 4px; padding: 2px 5px; border-radius: 6px; background: var(--ink); color: #fff; font: 700 12px/1 var(--mono); }
.tile.can { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px #ffffff, 0 0 0 9px var(--ink); }
.tile.spent .pic { filter: grayscale(0.7) brightness(0.9); }
.tile.focus { transform: translateY(-4px); }
.tile.picked { box-shadow: 0 0 0 4px var(--focus), 0 0 0 8px #fff; transform: translateY(-6px); }
.tile.target { box-shadow: 0 0 0 4px #b3261e, 0 0 0 8px #fff; animation: glow 1s ease-in-out infinite; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 5px; }
.tile.hurt { animation: hurt 420ms ease; }
.tile.healed { animation: healed 420ms ease; }
/* Lit things glow (a shadow), they don't move: a target stays put under a thumb. */
@keyframes glow { 50% { filter: drop-shadow(0 0 6px var(--focus)); } }
@keyframes pulse { 50% { transform: scale(1.04); } }
@keyframes hurt { 20% { transform: translateX(-6px) rotate(-2deg); } 40% { transform: translateX(6px) rotate(2deg); filter: brightness(1.6); } 70% { transform: translateX(-3px); } }
@keyframes healed { 40% { transform: scale(1.07); filter: brightness(1.2); } }

.slot { aspect-ratio: 5 / 7; width: var(--tw); border: 2px dashed #14141466; border-radius: 10px; background: transparent; cursor: default; }
.slot.lit { border: 3px solid var(--focus); background: #1e5aa822; cursor: pointer; animation: glow 1s ease-in-out infinite; }
.slot:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.band { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 4px; }
.turn { font: 900 18px/1 var(--display); }
.band .end { align-self: auto; min-height: 44px; padding: 10px 18px; font-size: 16px; }
.band .end.nudge { animation: glow 1.2s ease-in-out infinite; }

.sheet { position: fixed; left: max(16px, calc(50vw - 15rem + 16px)); right: max(16px, calc(50vw - 15rem + 16px)); bottom: calc(var(--sab) + 8px); z-index: 4; box-shadow: 0 8px 24px #0004; padding: 8px 48px 8px 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; display: flex; flex-direction: column; gap: 6px; }
.shead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sname { font: 800 22px/1 var(--name); }
.ssub { font: 500 12px/1 var(--mono); color: var(--muted); }
.stext { font: 500 14px/1.3 var(--body); }
.shint { font: 700 14px/1.3 var(--body); color: var(--focus); }
.sbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.sbtns .primary, .sbtns .secondary { align-self: auto; min-height: 44px; padding: 10px 16px; font-size: 15px; }
.sclose { position: absolute; right: 4px; top: 4px; font: 400 28px/1 var(--body); }

.hp { white-space: nowrap; }
.hp svg { width: 1.06em; height: 1.06em; vertical-align: -0.18em; margin: 0 0.16em 0 0.1em; }

.overlay { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: var(--paper); border-radius: 19px; }
.overlay h2 { font: 900 clamp(26px, 8vw, 36px)/1.05 var(--display); outline: none; }
.overlay p { color: var(--muted); max-width: 22rem; }
.obtns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.obtns .primary { align-self: auto; }


@media (prefers-reduced-motion: reduce) {
  .tile, .slot, .band .end { animation: none !important; transition: none; }
  .tile.target, .slot.lit { animation: none; }
}

/* --- the 3D table (board3d.js) ------------------------------------------------ */
.battle-head { grid-template-columns: 44px minmax(0, 1fr) 44px 44px; }
.view-toggle { font: 700 14px/1 var(--mono); border: 3px solid var(--ink); border-radius: 10px; width: 44px; height: 44px; background: #fff; }
.view-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.board.b3d { height: calc(100dvh - 118px - var(--sab)); min-height: 440px; }
.stage-host { position: relative; flex: 1 1 0; min-height: 0; border-radius: 14px; overflow: hidden; }
.stage-host canvas.stage3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; outline: none; }
.stage-host canvas.stage3d:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font: 800 40px/1 var(--name); color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: rise 1.1s ease-out forwards; }
.float.heal { color: #b6f0c0; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
/* On the 3D board the sheet lies over the bottom of the table (the hand). */
.stage-host .sheet.inflow { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 4; box-shadow: 0 -4px 16px #0003; padding: 8px 44px 8px 12px; gap: 4px; }
.stage-host .sheet.inflow .stext { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .float { animation-duration: 0.01s; } }

/* The 3D board gives the table the width: the frame hugs it. */
.board.b3d { padding: 6px 4px 8px; margin: 0 -10px; }
.board.b3d { gap: 4px; }
.board.b3d .banner { padding: 3px 8px 3px 6px; gap: 10px; border-width: 2px; border-radius: 14px; }
.board.b3d .tile.avatar { --tw: 50px; width: 50px; }
.board.b3d .bighp { width: 48px; height: 48px; }
.board.b3d .wname { font-size: 19px; }
.board.b3d .band { min-height: 44px; }
.board.b3d { height: calc(100dvh - 104px - var(--sab)); }

/* Chips: what a hit would do, on the cards it can reach (flat tiles, and the 3D table's overlay). */
.hitchip { position: absolute; z-index: 3; left: 50%; top: 42%; transform: translate(-50%, -50%); font: 800 22px/1 var(--name); color: #fff; background: #b3261e; border: 3px solid var(--ink); border-radius: 10px; padding: 4px 8px; white-space: nowrap; pointer-events: none; }
.hitchip.lethal { background: var(--ink); color: #ffd23f; }
.hitchip.heal { background: #1f7a3a; }
.floats.hitchips { z-index: 3; }
.floats.hitchips .hitchip { transform: translate(-50%, -50%); font-size: 20px; }
.tile .abil { position: absolute; left: 0; right: 0; bottom: 0; font: 700 11px/1.2 var(--mono); text-align: center; background: var(--paper); color: var(--ink); padding: 2px 2px 3px; border-top: 2px solid var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inkrow { display: flex; align-items: center; gap: 6px; }
.inktxt { font: 700 12px/1 var(--mono); }
.notes { display: flex; flex-direction: column; gap: 2px; padding: 0 6px; text-align: center; }
.recent { font: 600 13px/1.3 var(--mono); color: var(--ink); }
.coach { font: 600 14px/1.3 var(--body); color: #1e5aa8; }
.help-btn { font: 800 18px/1 var(--display); width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: 50%; background: var(--paper); }
.howto { text-align: left; max-width: 22rem; display: grid; gap: 8px; padding-left: 1.2em; }
.wheel { position: relative; width: 280px; height: 280px; flex: none; color: var(--ink); }
.wheel > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wstamp { position: absolute; width: 14.3%; height: 14.3%; background: var(--paper); border-radius: 50%; }
.wstamp svg { width: 100%; height: 100%; display: block; }
.worder { font: 800 14px/1.2 var(--display); }
/* Game over: the result sits at the foot, with the board still in view above it. */
.overlay.over { inset: auto 0 0 0; border-radius: 19px 19px 0 0; border-top: 3px solid var(--ink); padding: 16px; gap: 8px; box-shadow: 0 -8px 24px #0004; }
.overlay.over h2 { font-size: clamp(22px, 6vw, 30px); }
.slot.lit::after { content: "+"; display: grid; place-items: center; height: 100%; font: 800 30px/1 var(--display); color: var(--focus); }
.tile.inhand .cost { bottom: 24px; }
.wkey { font: 600 12px/1.3 var(--mono); margin-top: -8px; }
.overlay.help { position: fixed; inset: 6px 6px calc(var(--sab, 0px) + 56px) 6px; overflow: hidden; justify-content: flex-start; border: 3px solid var(--ink); z-index: 20; }
.hscroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.overlay.help { gap: 8px; padding-top: 12px; padding-bottom: 12px; }
.overlay.help .howto { font-size: 14px; gap: 5px; }
.overlay.help h2 { font-size: 26px; }
.wkey { display: grid; gap: 2px; }
.wkey p { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); }
.wkey svg { flex: none; }
.recent { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.overlay.help .obtns { flex: none; padding-top: 6px; }
@media (max-height: 640px) { .overlay.help .wheel { width: 210px; height: 210px; } }
.overlay.help .howto { font-size: 13px; line-height: 1.3; }
.overlay.help .wheel { width: 230px; height: 230px; }
@media (max-height: 640px) { .overlay.help .wheel { width: 200px; height: 200px; } }
@media (max-width: 300px) { .board { --tw: 56px; } .overlay.help .wheel { width: 160px; height: 160px; } }
.overlay.over .tile.winner { --tw: 64px; width: 64px; transform: rotate(-4deg); box-shadow: 0 0 0 3px #ffd23f, 0 4px 0 #0003; }
@media (max-height: 700px) { .overlay.over .tile.winner { display: none; } }

.band .thin { flex-basis: 100%; font: 700 11px/1.2 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: #6b6b6b; }
.band .thin.now { color: #b3261e; }
