:root{color-scheme:dark; font-family:system-ui,sans-serif; background:#0b1017; color:#eef4fa; font-size:14px}
*{box-sizing:border-box}
body{margin:0; min-height:100dvh; background:radial-gradient(ellipse at top,#1b2836 0%,#0b1017 50%); touch-action:manipulation}
main{max-width:410px; margin:auto; padding:max(env(safe-area-inset-top),9px) 13px max(20px,env(safe-area-inset-bottom))}
header,.board-label,.inline{display:flex; justify-content:space-between; align-items:center; gap:8px}
h1{font-size:21px; margin:0 0 3px; letter-spacing:.015em}
.kicker{font-size:9px; letter-spacing:.23em; color:#8ebac8; margin:0 0 2px}
nav{display:flex; gap:8px}
nav button{flex:1}
button,select,input{border:1px solid #42566c; border-radius:7px; color:inherit; background:#182434; font:inherit; padding:5px 8px}
button{min-height:32px; cursor:pointer; -webkit-user-select:none; user-select:none}
button:disabled{opacity:.45; cursor:default}
button:active:not(:disabled),button.held{background:#335b70}
button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid #70deea; outline-offset:2px}
p{line-height:1.35}
#notice{font-size:11px; margin:4px 0; color:#b9c8d6}
#share{font-size:11px; margin:4px 0}
.inline input{min-width:0; flex:1}
.boards{display:grid; justify-items:center; gap:4px}
.enemy,.self{width:min(100%, clamp(110px, calc((100svh - 275px) / 1.88), 292px)); color:#65dfed}
.enemy{width:min(90%, clamp(99px, calc((100svh - 275px) / 2.14), 258px));color:#fbaf9d}
.board-label{font-size:11px; font-weight:700; margin-bottom:2px}
.hp{letter-spacing:.18em}
.board{position:relative; display:grid; grid-template:repeat(5,1fr)/repeat(5,1fr); width:100%; aspect-ratio:1; gap:2px; padding:3px; border:1px solid currentColor; background:#101923; border-radius:7px; isolation:isolate; overflow:hidden}
.cell{background:#213342; border:1px solid #385164; border-radius:3px}
.enemy .cell{background:#312b36; border-color:#53424a}
.cell.warning,.enemy .cell.warning{background-image:linear-gradient(var(--warning-fill),var(--warning-fill));border-color:#ff9b64}
.cell.impact,.enemy .cell.impact{background:#f18a52;border-color:#ffe0a1}
.token{position:absolute; top:0;left:0; width:100%;height:100%; pointer-events:none}
.token::before{content:""; position:absolute; left:var(--x,50%); top:var(--y,50%); width:11%; height:11%; transform:translate(-50%,-50%); border:2px solid #f0f6fa; border-radius:29%; background:currentColor; box-shadow:0 0 0 3px #0b1017}
.controls{display:flex; justify-content:space-between; align-items:center; margin:6px auto 0; max-width:350px; gap:12px}
.pad{display:grid; grid-template-columns:repeat(3,44px); grid-template-rows:repeat(2,44px); gap:3px; touch-action:none}
.pad button{padding:0; font-size:23px; touch-action:none}
.pad button:first-child{grid-column:2}
.pad button:nth-child(2){grid-column:1}
.actions{display:grid; grid-template-columns:auto auto; gap:3px 5px; align-items:center}
.actions label{font-size:11px}
#attack{grid-column:1/-1; min-height:42px}
#attack{background:#764632; border-color:#d28157;font-weight:750}
details{border-top:1px solid #354357; margin-top:8px; padding-top:5px;color:#b9c8d6;font-size:12px}
summary{cursor:pointer}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:5px}
.stats div{display:grid;gap:2px;padding:5px;background:#172331;border-radius:4px}
.stats strong{color:#eef4fa; font-variant-numeric:tabular-nums}
#result{min-height:1.3em;margin:5px 0}
[hidden]{display:none!important}
#selfBoard{touch-action:none;user-select:none}
.board{overflow:visible;margin-top:9px}
.token::before{content:none}
.token{left:var(--x,50%);top:var(--y,50%);width:11%;height:11%;transform:translate(-50%,-50%);border:2px solid #eef4fa;border-radius:29%;background:currentColor;box-shadow:0 0 0 2px #0b1017}
.pawn-hp{position:absolute;bottom:calc(100% + 3px);left:50%;transform:translateX(-50%);width:20px;height:4px;background:#344554;border-radius:3px}
.pawn-hp i{display:block;width:var(--hp,100%);height:100%;background:#79dc96;border-radius:3px}
.power{width:min(100%,275.4px);margin:9px auto 7px;display:grid;grid-template-columns:47px minmax(0,1fr) 47px;align-items:center;gap:6px;font-size:12px;font-variant-numeric:tabular-nums}
.power>span:first-child{text-align:right}
.power-track{height:9px;border-radius:4px;background:#344554;overflow:hidden}
.power-track i{display:block;height:100%;background:#65dfed}
.actions{justify-content:center;grid-template-columns:repeat(3,minmax(0,71px));gap:10px}
.actions button{min-height:54px;font-size:12px}
.actions small{display:block}
.mini{display:grid;grid-template-columns:repeat(5,3px);gap:1px;width:max-content;margin:0 auto 3px}
.mini i{width:3px;height:3px;background:#42566c}
.mini i.on{background:#eef4fa}

#battleSurface,#battleSurface button,#selfBoard{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;touch-action:none}
#start,#lobby,#selection,#countdown{margin:18px auto;max-width:350px}
#start{flex-wrap:wrap}
#start button,#lobby button,#selection button,#goHome,#reconfigure{min-height:44px}
#lobby h2,#selection h2{font-size:18px}
#lobby #share{margin-bottom:12px}
#selection select{display:block;width:100%;margin:6px 0 12px}
#selection fieldset{border:1px solid #42566c;border-radius:8px;margin:0 0 12px}
#loadoutMoves label{display:flex;align-items:center;min-height:42px;gap:7px}
#countdown{text-align:center;font-size:18px}
.battle-nav{display:flex;justify-content:center;align-items:center;gap:8px}
.battle-nav:has(button:not([hidden])){margin:6px auto}
.battle-nav button{min-height:44px}
#reconfigure{display:block;margin:6px auto}
#loadoutCount{margin-left:7px;font-variant-numeric:tabular-nums}
#loadoutMoves label{min-height:52px;padding:5px 7px;margin:4px 0;border-radius:7px;border:1px solid transparent}
#loadoutMoves label.equipped{background:#182c38;border-color:#426072}
#loadoutMoves .mini{flex:none;grid-template-columns:repeat(5,4px);margin:0 4px}
#loadoutMoves .mini i{width:4px;height:4px}
#loadoutMoves small{display:block;color:#b9c8d6}
#loadoutMoves .signature{margin-left:6px;font-size:11px;color:#65dfed}
.charge-ring{position:absolute;left:50%;top:82%;width:145%;aspect-ratio:1;transform:translate(-50%,-50%);border-radius:50%;background:conic-gradient(#fff3ad var(--charge-progress,0%),#71563b var(--charge-progress,0%));mask:radial-gradient(farthest-side,transparent 67%,#000 72%);box-shadow:0 0 7px #ffc663}

html.battle-active,
html.battle-active body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}
html.battle-active body {
  position: fixed;
  inset: 0;
  height: 100dvh;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.battle-active main {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.battle-active #battleSurface {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto auto;
}
.battle-active .boards {
  container-type: size;
  grid-template-rows: 47fr 53fr;
  align-items: center;
  gap: 0;
}
.battle-active .enemy { width: min(90%, 258px, max(0px, calc(47cqh - 9px))); }
.battle-active .self { width: min(100%, 292px, max(0px, calc(53cqh - 9px))); }
.cell{position:relative;min-width:0}
.cell.aim{outline:1px dashed #ffad74;outline-offset:-3px}

.actions.four-moves{grid-template-columns:repeat(4,minmax(0,71px))}
.actions.four-moves button{min-width:0;padding:4px 1px;font-size:11px}
.support-icon{display:block;height:19px;line-height:19px;font-size:17px;font-weight:700;color:#a3e1f8;text-align:center}
.token.hastened{outline:2px solid #e1b5ff;outline-offset:2px}


/* Both selection screens share the same header and bottom controls. */
.selection-active main{display:flex;flex-direction:column;min-height:100dvh;padding-bottom:max(9px,env(safe-area-inset-bottom))}
.selection-active #notice:empty{display:none}
#selection.selection-screen,#moveSelection.selection-screen{
  display:flex;flex:1;flex-direction:column;gap:7px;width:100%;max-width:384px;margin:7px auto 0
}
.selection-screen h2{margin:0;font-size:20px;line-height:1.25}
#selection h2{color:#e9f1fb}
.selection-screen button{min-height:44px}
.selection-screen button[aria-pressed=true]{background:#214052;border-color:#65dfed}
.selection-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
#moveCharacter{font-size:12px;color:#b9c8d6}
#characters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
#selection .character-card{
  display:grid;align-content:center;justify-items:center;gap:3px;min-width:0;min-height:77px;padding:4px 2px;
  line-height:1.15;font-size:13px;color:#e9f1fb
}
.character-thumbnail{position:relative;overflow:hidden;width:51px;aspect-ratio:1;border-radius:6px;background:#111c28}
.character-thumbnail img{position:absolute;height:auto}
.selection-pager{display:grid;grid-template-columns:44px minmax(52px,auto) 44px;align-items:center;justify-content:center;gap:6px;text-align:center}
.selection-pager button{padding:0;font:600 23px/1 system-ui,sans-serif}
.selection-pager span{font-size:12px;color:#b9c8d6;font-variant-numeric:tabular-nums}
#selection .character-detail{
  position:relative;isolation:isolate;overflow:hidden;min-height:210px;display:flex;flex-direction:column;
  justify-content:space-between;gap:12px;padding:10px;border:1px solid #3d5368;border-radius:10px;
  background:radial-gradient(ellipse at 80% 35%,#233948,#152231 67%)
}
#characterArt{position:absolute;top:0;right:0;height:auto;pointer-events:none}
#characterArt[data-character="A"]{width:min(90%,355px);right:calc(-20% + 20px)}
#characterArt[data-character="B"]{width:min(82%,303px);top:-8px}
#characterArt[data-character="C"]{width:min(73%,280px);top:1px}
#characterArt[data-character="D"]{width:min(66%,243px);top:-8px;transform:scale(.9);transform-origin:40% 16%}
.character-summary,#loadoutMoves{position:relative}
#characterName{margin:1px 0 7px;font-size:20px;line-height:1.3}
.character-stats{display:flex;flex-wrap:wrap;gap:4px 12px;font-size:13px}
#selection #characterName,#selection .character-stats span{color:#e9f1fb;text-shadow:0 1px 4px #101721,0 1px 2px #101721}
#selection .character-card strong,#selection .character-detail strong,#loadoutMoves,.character-basic-facts span{color:#e9f1fb}
#loadoutMoves{
  display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;
  border:1px solid #516779;border-radius:8px;padding:8px 9px;background:rgb(16 26 36 / 84%);
  font-size:12px;line-height:1.45
}
.character-move-facts{display:grid;gap:4px}
.character-move-heading span{color:#b6cadb;margin-right:5px}
.character-basic-facts{display:grid;grid-template-columns:max-content max-content;gap:2px 10px;white-space:nowrap}
.character-move-facts small{font-size:11px;color:#b9c8d6}
#loadoutMoves .mini{grid-template-columns:repeat(5,9px);gap:2px;margin:0}
#loadoutMoves .mini i{width:9px;height:9px;border-radius:1px;background:#394e61}
#loadoutMoves .mini i.on{background:#65dae8;box-shadow:inset 0 0 0 1px #96e9f3}
#onlineMoveTabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
#onlineMoveTabs button{padding:2px;font-size:12px}
#moveSlots{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
#moveSlots button{padding:3px 1px;line-height:1.2;min-width:0}
#moveSlots small,#moveSlots strong{display:block}
#moveSlots small,.choice-label small{font-size:11px;color:#b9c8d6}
#moveSlots strong{margin-top:3px;font-size:12px;overflow-wrap:anywhere}
#moveCandidates{display:grid;position:relative;align-content:start;gap:6px}
#moveChoices,.move-choice-measure{display:grid;gap:4px}
.move-choice-measure{position:absolute;inset:0 0 auto;visibility:hidden;pointer-events:none}
.move-selection-active main{height:100dvh;min-height:0}
.move-selection-active #moveSelection{min-height:0}
#moveSelection > *{flex-shrink:0}
#moveSelection > #moveCandidates,#moveSelection > #moveDetails{flex:1;min-height:0}
.move-choice{display:grid;grid-template-columns:minmax(0,1fr) 49px;gap:5px}
.pick-move{display:grid;grid-template-columns:25px minmax(0,1fr) auto;align-items:center;gap:5px;padding:3px 5px;text-align:left}
.pick-move .mini{margin:0 auto}
.choice-label{display:grid;gap:2px;line-height:1.15;min-width:0}
.choice-slot{font-size:11px;color:#86dbe4;white-space:nowrap}
.inspect-move,#closeMoveDetails{padding:4px;font-size:12px;white-space:nowrap}
#moveDetails{border-top:1px solid #384b5a;padding-top:4px}
.move-detail-heading{display:flex;justify-content:space-between;align-items:center;gap:7px}
#detailName{font-size:16px;margin:0}
#detailType,#detailFacts,#detailNote{font-size:12px;margin:4px 0;color:#c0cdda}
#previewStage{display:flex;justify-content:center;gap:18px;margin:7px 0 3px}
#previewStage figure{display:grid;justify-items:center;gap:3px;margin:0}
#previewStage figcaption,#previewPhase{font-size:11px;color:#b9c8d6;text-align:center;margin:0}
.preview-board{display:grid;grid-template-columns:repeat(5,11px);grid-auto-rows:11px;gap:2px}
.preview-board i{display:block;border-radius:2px;background:#283a48}
.preview-board .preview-mark,.preview-board .preview-pawn{background:#86dbe4}
.preview-board .preview-pawn{border-radius:50%}
.preview-board .preview-warning{background-image:linear-gradient(var(--preview-fill),var(--preview-fill))}
.preview-board .preview-impact{background:#f18a52}
.preview-board .preview-charge{outline:1px dashed #ffbd70;outline-offset:1px}
.preview-board .preview-haste{outline:1px solid #e1b5ff;outline-offset:1px}
.preview-hp{width:49px;height:4px;border-radius:3px;background:#384b5a;overflow:hidden}
.preview-hp i{display:block;height:100%;background:#79dc96}
.selection-nav{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin-top:auto;padding-top:6px}
.selection-nav button{padding:4px}
.selection-nav .selection-primary{background:#214052;border-color:#65dfed}
@media (max-height:520px){
  .selection-active header .kicker{display:none}
  #selection.selection-screen,#moveSelection.selection-screen{gap:4px;margin-top:3px}
  .selection-screen h2{font-size:18px}
  #selection .character-card{min-height:70px;gap:1px}
  #selection .character-detail{min-height:170px}
  .preview-board{grid-template-columns:repeat(5,9px);grid-auto-rows:9px}
}
@media (max-width:355px){
  #selection .character-detail{min-height:180px}
}
#moveCategories{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
#moveCategories button{padding:3px 1px;font-size:12px}
#emptyCategory{margin:6px 0;color:#b9c8d6;font-size:12px;text-align:center}
.character-card strong{font-size:12px;white-space:nowrap}
.token.charge-ready::after,.preview-board .preview-ready::after,.preview-board .preview-opponent::after{
  content:"";position:absolute;width:5px;height:5px;transform:rotate(45deg);
  background:#ffe29a;box-shadow:0 0 0 1px #101923;pointer-events:none
}
.token.charge-ready::after{right:-4px;top:-3px}
.preview-board .preview-ready,.preview-board .preview-opponent{position:relative}
.preview-board .preview-ready::after{right:-2px;top:-2px}
.preview-board .preview-opponent::after{inset:0;margin:auto}
#worldLane{display:none}
.time-duel #worldLane{display:grid;place-items:center;width:100%;min-height:24px}
#worldCue{display:flex;align-items:center;gap:6px;padding:2px 8px;border-radius:6px;background:#263749;color:#ffe0a3;font-size:12px;font-weight:700;line-height:1.3}
#worldCue i,.slow-clock{position:relative;display:inline-block;width:14px;height:14px;border:1px solid #ffe0a3;border-radius:50%}
#worldCue i::after,.slow-clock::after{content:"";position:absolute;left:50%;bottom:50%;height:4px;width:1px;background:#ffe0a3;transform-origin:50% 100%}
#worldCue i::after{transform:rotate(12deg);animation:clock-stop .23s ease-out both}
@keyframes clock-stop{from{transform:rotate(-100deg)}to{transform:rotate(12deg)}}
.slow-clock{position:absolute;right:-9px;bottom:-6px;border-color:#101923;background:radial-gradient(circle,#192736 55%,transparent 60%),conic-gradient(#ffe0a3 var(--slow-progress),#41556a 0);pointer-events:none}
.preview-board .preview-slow{outline:1px solid #ffe0a3;outline-offset:1px}
.battle-active .time-duel .boards{grid-template-rows:minmax(0,47fr) 24px minmax(0,53fr)}
.battle-active .time-duel .enemy{width:min(90%,258px,max(0px,calc(47cqh - 21px)))}
.battle-active .time-duel .self{width:min(100%,292px,max(0px,calc(53cqh - 22px)))}
@media(prefers-reduced-motion:reduce){#worldCue i::after{animation:none}}
