/* The battle controls have their own rows so they never cover the boss. */
#game {
  --night:#160d24;
  --panel:#291839;
  --paper:#fff8ed;
  --mint:#4ce6c5;
  --pink:#ff72bb;
  --gold:#ffd65a;
  --white:#fff8fb;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) clamp(218px,30dvh,305px);
  background:var(--night);
  color:var(--white);
}
#game > .battleHeader {
  position:relative;
  inset:auto;
  z-index:2;
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto auto;
  align-items:center;
  gap:clamp(8px,1.8vw,26px);
  padding:9px clamp(12px,2.1vw,30px) 10px;
  background:linear-gradient(100deg,#261337,#160f27 55%,#292046);
  border-bottom:3px solid var(--mint);
  color:var(--white);
}
.battleHeader .brand {
  font-size:clamp(19px,2.1vw,31px);
  font-weight:1000;
  text-shadow:2px 3px #000;
  color:#fff4fc;
}
.battleHeader .brandSymbol {
  display:grid;
  place-items:center;
  width:40px;height:42px;
  color:#331948;background:var(--gold);
  clip-path:polygon(50% 0,62% 30%,94% 15%,82% 47%,100% 74%,66% 74%,50% 100%,33% 74%,0 74%,18% 47%,6% 15%,38% 30%);
}
.battleHeader .brand small {color:var(--pink);font-size:10px;letter-spacing:.1em;text-shadow:none}
.headerStatus {width:min(100%,660px);margin-inline:auto;min-width:0}
#stageinfo {width:100%;max-width:none;margin:0}
.stageLine {gap:8px}
.stageLine b {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:clamp(13px,1.45vw,19px)}
.stageLine span {display:inline;color:#bdf6eb;font-size:clamp(10px,1vw,13px);white-space:nowrap}
.progressTrack,.bossTrack,.moraleTrack {background:#100b20;border:1px solid #9472a9;border-radius:5px;overflow:hidden}
.progressTrack {height:9px;margin:4px 0}
.progressTrack i,.moraleTrack i {background:linear-gradient(90deg,#47c6ed,#57ffbc)}
.phaseLabels {color:#d9caed}
#bossHud {
  position:static;
  inset:auto;
  transform:none;
  width:100%;
  padding:0;
  background:none;
  border:0;
  border-radius:0;
  color:var(--white);
}
#bossHud b {font-size:clamp(13px,1.45vw,19px);color:#ffd6ee}
#bossPhase {color:#ffcf79;font-weight:800;white-space:nowrap}
.bossTrack {height:11px;margin:4px 0 2px}
.bossTrack i {background:linear-gradient(90deg,#a237d4,#ff54a5 72%,#ff9d7e)}
#weakness {color:#efd9ff}
.battleHeader .health small {display:block;color:#c5f9ed}
#hearts {color:#ff81bb;font-size:clamp(13px,1.5vw,21px);letter-spacing:.09em}
.headerTools .icon {
  border:1px solid #85639f;
  background:#33204c;
  box-shadow:0 3px #090712;
  color:#fff9fb;
  border-radius:9px;
}
.headerTools .icon:hover,.headerTools .icon[aria-pressed="true"] {background:#51316d}
#field {background:#21112d}
.fieldBottom {bottom:8px;color:#fff4fa;text-shadow:0 2px 3px #110820}
.battleInfo button {background:#291842;color:#fff;border-color:#ab80d0;text-shadow:none}
#battleToast,#pauseLabel {
  background:#211235ee;color:#ffeed5;
  border:1px solid #bc85ef;
  box-shadow:0 3px #100a1c88;
}
#battleToast {top:10%;padding:5px 16px;font-size:clamp(13px,1.5vw,19px)}
#pauseLabel {bottom:42px}
#desk {
  border:0;
  border-top:3px solid var(--pink);
  padding-inline:clamp(12px,2.1vw,30px);
  background:
    radial-gradient(ellipse at 12% 110%,#4c2459,transparent 51%),
    radial-gradient(ellipse at 97% 105%,#164456,transparent 43%),
    #22152f;
  color:var(--white);
  box-shadow:none;
}
.deskTop {height:35px;border-color:#765983;font-weight:800}
.deskTop > span:first-child {color:var(--pink);letter-spacing:.08em}
.deskTop #resultLabel {color:#f6e9ff;font-size:clamp(11px,1.2vw,15px)}
.deskTop button,.qualitySteps span {color:#eee1fe;background:#392653;border-color:#a481bc}
.deskTop button {border:1px solid #85639f;border-radius:6px;padding:3px 9px}
.workspace {gap:clamp(8px,1.35vw,24px)}
.writeCard {
  border:2px solid #ffc9ef;
  outline:2px solid #8d459d;
  outline-offset:2px;
  box-shadow:0 5px #130921;
  background:#fff9ee;
}
#writeTarget {color:#663c73}
.padTag {color:#785a7c}
.tools button {
  background:#38264f;
  color:#f7eaff;
  border:1px solid #aa84c0;
  box-shadow:0 3px #150c24;
}
.unitPreview {
  padding:7px 0;
  border-radius:12px;
  background:radial-gradient(ellipse at center,#633a7e,#35224d 66%,transparent 67%);
}
.unitCaption b {color:#fff}
.unitCaption small,#learningHint,#summonHelp {color:#decde9}
.previewArt img {filter:drop-shadow(0 2px 2px #151026)}
#feedback {color:#fff3ff;font-size:clamp(14px,1.65vw,23px);text-wrap:balance}
.qualitySteps .active {background:#62e6c9;border-color:#c1ffee;color:#172d36}
.qualitySteps [data-tier=elite].active {background:#ffd55c;border-color:#ffe5ab;color:#402643}
.qualitySteps [data-tier=rough].active {background:#f08bbd;border-color:#f9badb;color:#371c35}
#metrics {color:#ead7f6}
#summon {
  background:linear-gradient(168deg,#fff297,#ffc94c 61%,#ffad44);
  color:#241430;
  border:2px solid #fff2bd;
  box-shadow:0 5px #a74169,0 8px #160d24;
  border-radius:13px;
}
#summon:active {box-shadow:0 2px #a74169}
#modal,.menu-open #modal {
  background:#ffeff9;color:#2e1739;border:3px solid #4a265e;
  box-shadow:0 0 0 3px #f7a5dd,0 22px 80px #10091b88;
}
#modal h1,#modal h2 {color:#31183f}
#modal h1 span,#modal .eyebrow {color:#9a3270}
#modal p,.steps div {color:#574365}
#modal .smallNote {color:#695573!important}
.steps div,.settingsGrid label,.collectionCard {background:#f0dff6}
.steps b,.settingsGrid label,.collectionCard small {color:#54336c}
.settingsGrid select {color:#49235a;border-color:#ba9ece}
.primary {background:#5a327c;color:#fff5fb;box-shadow:0 3px #371d55}
.primary.gold {background:#ffcb52;color:#392035;box-shadow:0 3px #b96553}
.secondary,.reviewRow button,.stages button {background:#ead7f5;color:#4f3164;box-shadow:0 3px #cfb4e0}
.stages button.current {background:#6d3798;color:#fff}
.resultStats b,.resultStats span {color:#553167}
#loading {background:#1d122a;color:#fff3f9}
.loadingMark,#loadingStatus {color:#ffc3ed}
@media(max-height:650px) and (orientation:landscape) {
  #game {grid-template-rows:auto minmax(0,1fr) clamp(121px,35dvh,223px)}
  #game > .battleHeader {padding-block:5px}
  .battleHeader .brandSymbol {height:32px;width:31px}
  .deskTop {height:27px}
  .fieldBottom {bottom:3px}
  #pauseLabel {bottom:30px}
}
@media(max-width:880px) {
  #game > .battleHeader {grid-template-columns:auto minmax(0,1fr) auto}
  .battleHeader .health {display:none}
  .headerTools .icon {width:34px;height:36px}
  .workspace {gap:10px}
  .stageLine span {font-size:9px}
}
@media(orientation:portrait) {
  #game {grid-template-rows:auto minmax(0,1fr) minmax(0,48dvh)}
  #game > .battleHeader {grid-template-columns:minmax(0,1fr) auto;gap:7px;padding:7px 10px}
  .battleHeader .brandSymbol {display:none}
  .headerStatus {grid-row:2;grid-column:1/-1}
  .stageLine span {white-space:normal;text-align:right}
  .workspace {gap:7px}
  .unitPreview {min-width:0}
  #orientation {display:none}
}

/* Keep writing and confirmation within one hand's reach. */
.workspace {width:min(100%,1100px);margin-inline:auto}
.writingActions {
  display:flex;
  flex:0 0 auto;
  flex-direction:column;
  gap:8px;
  align-items:stretch;
}
.writingActions .tools {flex-direction:row;gap:7px}
.writingActions .tools button {flex:1;min-width:44px;min-height:44px}
#summon {
  width:clamp(114px,15vw,166px);
  height:auto;
  min-height:58px;
  padding:8px 10px;
  text-align:center;
  font-size:clamp(22px,2.2vw,31px);
  line-height:1.1;
}
#summon:focus-visible,.tutorial button:focus-visible {outline:3px solid #4ce6c5;outline-offset:3px}
#writeTarget {color:#5a2e72;font-size:clamp(22px,3.5dvh,33px);pointer-events:none}
#desk.beginner .qualitySteps,#desk.beginner #tierBadge {display:none}
.settingsGrid label small {font-size:11px;font-weight:500;line-height:1.3}

.tutorial {max-width:520px;margin:auto}
.tutorial h2 {margin:0 0 5px}
.tutorialSteps {font-size:24px;color:#a8511e;font-weight:900;line-height:1.2}
.tutorialArea {
  display:flex;
  justify-content:center;
  align-items:center;
  gap:12px;
  margin:9px auto;
}
.tutorialPaper {
  position:relative;
  width:min(53vw,50dvh,254px);
  aspect-ratio:1;
  border:3px solid #8e4a9f;
  border-radius:14px;
  background:#fff9ee;
  overflow:hidden;
}
#tutorialWriting {display:block;width:100%;height:100%;touch-action:none;cursor:crosshair}
#tutorialDigit {position:absolute;top:7px;left:10px;font-size:25px;color:#593770;font-weight:800;pointer-events:none}
.tutorialControls {display:grid;gap:8px}
.tutorialControls b {font-size:clamp(16px,3vw,23px);color:#5a327c}
.tutorialControls button {min-height:44px;padding:7px 12px}
.tutorialTeam {display:flex;justify-content:center;gap:8px;min-height:min(12dvh,76px)}
.tutorialTeam img {width:clamp(40px,11vw,84px);height:min(12dvh,76px);object-fit:contain}
#tutorialFeedback {margin:8px 0;font-size:14px}
.tutorial .actions {margin-top:8px}

@media(max-height:520px) and (orientation:landscape) {
  #game {grid-template-rows:auto minmax(0,1fr) clamp(152px,40dvh,204px)}
  #desk {padding-bottom:5px}
  .workspace {padding-block:6px}
  .writingActions {gap:6px}
  #summon {min-height:51px}
  .tutorialPaper {width:min(53vw,42dvh,205px)}
  #modal:has(.tutorial) {padding-block:12px}
}
@media(orientation:portrait) {
  .workspace {
    grid-template-columns:minmax(0,1fr) clamp(102px,29vw,151px);
    grid-template-rows:minmax(0,1fr) auto;
    align-content:center;
    column-gap:9px;
  }
  .writeCard {justify-self:end;width:min(100%,56vw,29dvh);height:auto;max-height:none}
  .writingActions {grid-column:2;grid-row:1;justify-self:start}
  .writingActions .tools {grid-column:auto;grid-row:auto}
  .unitPreview {grid-column:2;grid-row:2;height:61px;padding:3px;justify-self:start}
  .unitCaption small {display:none}
  .previewArt {padding-bottom:0}
  .quality {grid-column:1;grid-row:2;width:100%}
  #summon {width:clamp(102px,29vw,151px)}
}
