/* A pocket battle made from the same paper as the site: cut-out scenery, ink frames, and a command box. Its sheet is sheet.css. */
.battle-arena { position: relative; isolation: isolate; height: clamp(225px, calc(100dvh - 450px), 315px); margin: 6px 0 10px; overflow: hidden; border: 2px solid var(--ink); background: #f8f1d9 var(--grain); border-radius: 4px 7px 3px 4px; }
/* The folds sit behind the fighters. Nothing in this scenery comes from a generated theme. */
.battle-arena::before { content: ''; position: absolute; inset: 42% -4% -5%; z-index: -2; background: #cad0ad var(--grain); clip-path: polygon(0 16%, 22% 22%, 55% 0, 79% 11%, 100% 6%, 100% 100%, 0 100%); }
.battle-arena::after { content: ''; position: absolute; inset: 65% -4% -8%; z-index: -1; background: #b6bf98 var(--grain); clip-path: polygon(0 12%, 34% 0, 57% 15%, 100% 25%, 100% 100%, 0 100%); }
.battle-ground { position: absolute; height: 17%; background: #e6dcb7 var(--grain); border-radius: 50%; box-shadow: 0 4px 0 #7c866641, inset 0 -3px 0 #d1c299; rotate: -4deg; z-index: -1; }
.enemy-ground { width: 41%; right: 2%; top: 37%; }
.your-ground { width: 47%; left: 1%; bottom: 2%; }
.battle-picture { position: absolute; display: flex; justify-content: center; align-items: flex-end; transform: none; filter: drop-shadow(1.5px 3px 0 #1f2a4430); }
.battle-picture img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.enemy-picture { width: 38%; height: 41%; right: 3%; top: 7%; rotate: 2deg; }
.your-picture { width: 43%; height: 46%; left: 3%; bottom: 7%; rotate: -2deg; }
.battle-picture.faces-left { scale: -1 1; }
.battle-picture.faces-left .battle-damage { scale: -1 1; }
.battle-stats { position: absolute; z-index: 3; width: 49%; padding: 9px 10px 7px; background: #fffdf1 var(--grain); border: 2px solid var(--ink); border-radius: 3px 8px 3px 3px; box-shadow: 3px 3px 0 #1f2a4440; }
.enemy-stats { left: 10px; top: 14px; rotate: -1deg; }
.your-stats { right: 10px; bottom: 18px; rotate: 1deg; }
.battle-owner { position: absolute; top: -10px; left: 8px; padding: 0 5px; background: #fffdf1; font: 700 9px 'Space Mono', monospace; letter-spacing: .8px; text-transform: uppercase; }
.battle-name { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 5px; }
.battle-name b { font-size: 20px; font-weight: 900; line-height: 1.15; }
.battle-type { color: #5e6253; font: 700 9px 'Space Mono', monospace; }
.battle-hp { display: flex; align-items: center; gap: 5px; margin-top: 8px; }
.battle-hp > b { color: #9a6c28; font: 700 11px 'Space Mono', monospace; }
.battle-health { flex: 1; height: 10px; border: 1.5px solid var(--ink); border-radius: 5px; overflow: hidden; background: #e0d9c4; }
.battle-health > span { display: block; height: 100%; background: #4b9270; box-shadow: inset 0 2px #ffffff60; transition: width 450ms ease-out; }
.battle-health > span.low { background: #d76b4b; }
.battle-numbers { display: flex; justify-content: space-between; margin-top: 4px; min-height: 12px; font: 700 10px 'Space Mono', monospace; }
.battle-numbers > span:first-child { color: #776593; font-size: 9px; }
.battle-numbers > span:last-child { white-space: nowrap; }
.battle-command { position: relative; height: 250px; min-height: 250px; display: flex; flex-direction: column; padding: 13px 14px 9px; background: #fffdf1 var(--grain); border: 3px solid var(--ink); border-radius: 6px 4px 5px 7px; box-shadow: inset 0 0 0 3px #fffdf1, inset 0 0 0 4px #a5aa98; }
.battle-text { margin: 0; flex: 0 0 40px; min-height: 40px; display: flex; align-items: center; font-size: 18px; font-weight: 900; line-height: 1.3; }
.battle-result { margin: 0; flex: 0 0 32px; font-size: 11px; color: #686652; font-weight: 700; min-height: 32px; line-height: 1.2; padding-top: 5px; }
.battle-result:empty { visibility: hidden; }
.battle-moves { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; column-gap: 14px; margin-top: 3px; }
.battle-moves button { position: relative; display: flex; flex-direction: column; justify-content: flex-start; text-align: left; background: none; border: 0; border-bottom: 1px dashed #b8b49f; border-radius: 0; padding: 12px 0 6px 13px; min-width: 0; min-height: 65px; }
.battle-moves button:nth-last-child(-n+2) { border-bottom: 0; }
.battle-moves b::before { content: '▸'; position: absolute; left: -13px; top: 0; font-size: 14px; line-height: inherit; opacity: .55; }
.battle-moves button:not(:disabled):hover b::before, .battle-moves button:focus-visible b::before { opacity: 1; }
.battle-moves button:not(:disabled):hover { background: #ede5c5; }
.battle-moves b { position: relative; display: block; font-size: 16px; font-weight: 900; }
.battle-moves small { display: block; font-size: 12px; font-weight: 700; color: #666552; margin-top: 3px; }
.battle-moves button:disabled { cursor: default; opacity: .4; }
.battle-moves .battle-again, .battle-moves .battle-done { margin-top: 13px; text-align: center; min-height: 60px; font-size: 19px; font-weight: 900; padding-left: 0; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); background: #f2d478; rotate: -1deg; }
.battle-moves .battle-done { background: #ede7d4; rotate: 1deg; }
.battle-hint.battle-warning { color: #95412f; font-weight: 900; }
.battle-hint { font-size: 10px; color: #73745e; margin: 3px 0 0; min-height: 13px; }
#battle:is([data-phase='intro'],[data-phase='attack'],[data-phase='thinking'],[data-phase='knockout']) .battle-moves { visibility: hidden; }
#battle:is([data-phase='intro'],[data-phase='attack'],[data-phase='thinking'],[data-phase='knockout']) .battle-text { font-size: 22px; align-items: flex-start; padding-top: 5px; }
#battle:is([data-phase='intro'],[data-phase='attack'],[data-phase='thinking'],[data-phase='knockout']) .battle-result { position: absolute; top: 88px; left: 14px; right: 14px; font-size: 19px; color: var(--ink); }
#battle:is([data-phase='intro'],[data-phase='attack'],[data-phase='thinking'],[data-phase='knockout']) .battle-hint { visibility: hidden; }
#battle:is([data-phase='intro'],[data-phase='attack'],[data-phase='knockout']) .battle-command::after { content: '···'; position: absolute; right: 15px; bottom: 12px; font-size: 24px; animation: battle-caret 800ms ease-in-out infinite alternate; }
#battle:is([data-phase='ended'], [data-phase='error']) .battle-moves { grid-template-rows: 1fr; align-items: center; }
.battle-moves .battle-again, .battle-moves .battle-done { align-items: center; justify-content: center; }
#battle[data-phase='ended'] .battle-result { color: #686652; }
.battle-banner { display: none; position: absolute; left: 24%; top: 74%; translate: -50% -50%; z-index: 5; width: max-content; max-width: 38%; padding: 4px 8px 6px; background: #efd276 var(--grain); border: 2px solid var(--ink); box-shadow: 3px 3px 0 #1f2a44; rotate: -6deg; font: clamp(18px, 5vw, 26px)/1.15 'Permanent Marker', cursive; text-align: center; }
.battle-banner.you-won { left: 77%; top: 28%; }
#battle[data-phase='ended'] .battle-banner { display: block; }
.battle-damage { position: absolute; z-index: 6; left: 45%; top: 30%; pointer-events: none; color: #fffdf1; text-shadow: -2px -2px var(--ink), 2px -2px var(--ink), -2px 2px var(--ink), 2px 2px var(--ink); font: 900 28px Nunito, sans-serif; }
.battle-scrap { position: absolute; left: 50%; top: 50%; width: 7px; height: 10px; pointer-events: none; }
#battle[data-phase='loading'] .battle-arena { opacity: .6; }
@keyframes battle-caret { to { opacity: .25; } }
@media (max-width: 700px) {
  .battle-arena { height: clamp(225px, 34dvh, 295px); }
  .battle-command { padding: 11px 12px 9px; }
  .battle-stats { width: 49%; padding: 8px 8px 5px; }
  .battle-name b { font-size: 19px; }
  .battle-moves { column-gap: 9px; }
  .battle-moves b { font-size: 15px; }
}
@media (max-height: 650px) and (max-width: 700px) {
  #battle { padding-top: 6px; padding-bottom: max(10px, env(safe-area-inset-bottom)); max-height: calc(100dvh - 54px); }
  .battle-arena { height: 195px; margin-bottom: 7px; }
  #battle #mute, #battle .game-close { width: 44px; height: 44px; }
  .battle-command { height: 233px; min-height: 233px; padding: 9px 10px 6px; }
  .battle-text { flex-basis: 28px; min-height: 28px; font-size: 16px; }
  .battle-moves button { min-height: 58px; padding-top: 6px; padding-bottom: 6px; }
  .battle-result { flex-basis: 26px; min-height: 26px; font-size: 10px; padding-top: 2px; }
  .battle-moves b { font-size: 14px; }
  .battle-moves small { font-size: 11px; }
  .battle-hint { margin-top: 3px; font-size: 9px; }
  .battle-name { flex-wrap: wrap; gap: 2px; }
  .battle-name b { font-size: 16px; }
  .battle-type { font-size: 8px; }
  .battle-numbers { font-size: 9px; }
  .battle-numbers > span:first-child { font-size: 8px; }
}
@media (max-width: 400px) {
  .battle-numbers { font-size: 9px; }
  .battle-numbers > span:first-child { font-size: 8px; }
}
@media (max-width: 400px) and (min-height: 651px) {
  .battle-command { height: 285px; min-height: 285px; }
  .battle-text { flex-basis: 32px; min-height: 32px; }
}
@media (max-height: 700px) and (min-width: 701px), (max-height: 500px) and (min-width: 520px) {
  #battle { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; width: min(790px, calc(100vw - 24px)); left: 50vw; top: 50dvh; bottom: auto; transform: translate(-50%, -50%); border-radius: 6px; max-height: calc(100dvh - 24px); padding: 8px 10px 12px; animation: none; }
  #battle .game-grab { display: none; }
  #battle .game-head { grid-column: 1 / -1; }
  #battle .game-head h2 { font-size: 18px; }
  .battle-arena { height: 255px; margin: 4px 0 0; }
  .battle-command { height: 255px; min-height: 255px; margin-top: 4px; padding: 10px 12px; }
  .battle-text { font-size: 18px; min-height: 44px; flex-basis: 44px; }
  .battle-moves b { font-size: 14px; }
  .battle-moves small { font-size: 11px; }
  .battle-name b { font-size: 16px; }
  .battle-stats { padding: 8px 6px 5px; }
  body.game-open .gremlin { width: 54px; height: 60px; }
}
@media (max-height: 500px) and (min-width: 520px) and (max-width: 700px) {
  .battle-banner { font-size: 16px; padding-inline: 5px; }
}
@media (max-height: 360px) and (min-width: 520px) {
  .battle-arena, .battle-command { height: 220px; min-height: 220px; }
  .battle-command { padding: 7px 9px; }
  .battle-text { font-size: 15px; min-height: 30px; flex-basis: 30px; }
  .battle-result { font-size: 10px; min-height: 26px; flex-basis: 26px; }
  .battle-moves { column-gap: 7px; }
  .battle-moves button { min-height: 50px; padding: 3px 0 3px 10px; }
  .battle-moves b { font-size: 12px; }
  .battle-moves b::before { left: -10px; font-size: 12px; }
  .battle-moves small { font-size: 10px; }
  .battle-hint { font-size: 9px; }
  .battle-name b { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  #battle, #battle * { animation: none !important; transition: none !important; }
}
