/* Shell, combat HUD and controls for the clockwork islands. */
:root {
  color-scheme: dark;
  --text: #f9eed9;
  --muted: #b8c8bd;
  --brass: #e7c98f;
  --glass: #19363a;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  color: var(--text);
  background-color: #101f24;
  background-image:
    radial-gradient(ellipse at 49% 25%, #42606175, transparent 72%),
    repeating-linear-gradient(118deg, #c8d0ad08 0 1px, transparent 1px 23px),
    repeating-linear-gradient(28deg, #c8d0ad06 0 1px, transparent 1px 23px),
    linear-gradient(145deg, #1f383b 0%, #112629 57%, #0e1c20 100%);
}
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid #ffe5a0; outline-offset: 3px; }
.shell {
  width: min(100%, 1440px, calc((100svh - 159px) * 1.88 + 36px));
  margin: auto;
  padding: 8px 18px 14px;
}
.mast { display: flex; align-items: center; gap: 23px; min-height: 63px; padding: 0 3px 6px; }
.brand, .battle-settings, .tools, .setting, .readout, #fire { display: flex; align-items: center; }
.brand { gap: 11px; flex-shrink: 0; }
.crest { width: 39px; height: 42px; filter: drop-shadow(0 2px 2px #07191c); }
h1 {
  margin: 0; color: #f7eacb;
  font: 800 clamp(24px, 2.2vw, 34px)/1.08 "Songti SC", STSong, SimSun, serif;
  letter-spacing: .1em; text-shadow: 0 2px 1px #081b1d;
}
.battle-settings {
  gap: 7px; padding-left: 20px;
  border-left: 1px solid #a5b9a545;
}
.setting, .tools button {
  min-height: 37px;
  border: 1px solid #a6956d75;
  background: linear-gradient(165deg, #335053, #213b3e 61%, #1b3438);
  box-shadow: inset 0 1px 0 #d8e4b817, 0 2px 2px #0c242e44;
}
.setting {
  justify-content: center; gap: 7px; min-width: 102px; padding: 0 10px;
  border-radius: 6px; color: #eddfc4; font-size: 13px; line-height: 1.2;
}
.setting .setting-icon { color: #d9c396; width: 16px; height: 16px; }
.setting .swap { width: 13px; height: 13px; color: #a6bbad; }
.setting:disabled, .tools button:disabled { opacity: .58; }
.tools { margin-left: auto; gap: 7px; }
.tools button {
  display: grid; place-items: center;
  width: 38px; padding: 0; border-radius: 50%; color: #ecddbd;
}
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linejoin: round; stroke-linecap: round; }
body:not(.audible) .sound-on, body.audible .sound-off { display: none; }
@media (hover: hover) {
  .tools button:hover:not(:disabled), .setting:hover:not(:disabled) { border-color: #d7ba82; background: #365457; }
}
.frame {
  position: relative;
  border: 1px solid #b39b70;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 45px #04111666, 0 0 0 2px #34504c, 0 0 0 3px #bbc39a20;
}
.field {
  position: relative; isolation: isolate; aspect-ratio: 1.88; overflow: hidden;
  user-select: none; touch-action: pan-y;
  background: linear-gradient(#8aacac, #cde7de 64%, #709a82);
}
.vista, #arena, .field-edge, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.vista { object-fit: fill; pointer-events: none; }
#arena { z-index: 2; }
.field-edge {
  z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 30px #0d344a1e;
  background: linear-gradient(180deg, #22474d1f, transparent 23%, transparent 92%, #172c2f2b);
}
#fx { pointer-events: none; z-index: 8; }
#muzzle { display: none !important; }
.corn { position: absolute; z-index: 12; pointer-events: none; width: 22px; height: 22px; border-top: 1px solid #fff0bbba; border-left: 1px solid #fff0bbba; }
.corn::after { content: ""; position: absolute; top: 3px; left: 3px; width: 4px; height: 4px; border: 1px solid #ffe4aa; transform: rotate(45deg); }
.tl { top: 5px; left: 5px; }
.tr { top: 5px; right: 5px; transform: rotate(90deg); }
.bl { bottom: 5px; left: 5px; transform: rotate(-90deg); }
.br { bottom: 5px; right: 5px; transform: rotate(180deg); }
.huds { position: absolute; z-index: 10; top: 3.6%; right: 2.5%; left: 2.5%; display: flex; justify-content: space-between; gap: 18px; pointer-events: none; }
.faction {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px 6px 6px; position: relative;
  color: #f7f2d9; background: linear-gradient(110deg, #112d35f2, #204a4ee8);
  border: 1px solid #cbccaa; border-left: 3px solid #83d2c7; border-radius: 5px 10px 5px 5px;
  box-shadow: inset 0 1px #dfe9bc1a, 0 2px 5px #152b3533;
}
.faction.sun { flex-direction: row-reverse; text-align: right; padding: 5px 6px 6px 10px; background: linear-gradient(250deg, #382d29f5, #664334e7); border: 1px solid #d7bf9c; border-right: 3px solid #e7a274; border-radius: 10px 5px 5px 5px; }
.sigil { display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border: 1px solid #b7c4a5; border-radius: 50%; color: #c7f0d6; background: radial-gradient(at 30% 10%, #528680, #244e51 80%); }
.sigil .icon { width: 20px; height: 20px; }
.sunmark { border-color: #ddb082; background: radial-gradient(at 30% 10%, #ac7358, #714231 80%); color: #ffdfa0; }
.faction-info { line-height: 1; }
.team { display: inline-block; margin-right: 5px; color: #d1e2cc; font-size: 11px; }
.sun .team { color: #f0d4b1; }
.faction strong { white-space: nowrap; font: 700 16px/1.1 "Songti SC", STSong, SimSun, serif; letter-spacing: .07em; }
.pips { display: flex; gap: 2px; align-items: center; margin-top: 5px; }
.sun .pips { justify-content: flex-end; }
.pips i { width: 6px; height: 4px; transform: skew(-10deg); border-radius: 1px; background: #9ce3cc; }
.pips i:nth-child(3n):not(:last-child) { margin-right: 2px; }
.sun .pips i { background: #f6b481; }
.pips i.lost { background: #65736a; opacity: .65; }

/* Base silhouettes are shared by the composition and combat styles. */
#buildings{position:absolute;inset:0;pointer-events:none}.tower{position:absolute;transform:translate(-50%,-100%);padding:0;border:0;background:none;line-height:0;pointer-events:none;transform-origin:50% 100%;isolation:isolate}.tower.enemy{pointer-events:auto;cursor:crosshair}.tower:before{content:"";position:absolute;left:0;bottom:-1.8%;width:102%;height:9%;border-radius:50%;background:#45392270;filter:blur(2px);z-index:-1}.tower img{width:100%;height:auto;display:block;pointer-events:none;filter:drop-shadow(1px 2px 1px #3428133a);user-select:none}.tower .body{display:block;position:relative}.tower.enemy:hover:not(.dead) img{filter:drop-shadow(0 0 2px #fffaca) brightness(1.08)}.tower .crack{position:absolute;inset:30% 19% 0 30%;background:#382b30;clip-path:polygon(28% 0,44% 23%,34% 36%,58% 55%,46% 69%,64% 92%,43% 69%,53% 55%,27% 36%,38% 23%);opacity:0}.tower[data-hp="2"] .crack,.tower[data-hp="1"] .crack{opacity:.89}.tower[data-hp="1"] .body img{filter:brightness(.84) saturate(.68)}.tower .badge{display:none;position:absolute;top:-8px;left:50%;transform:translate(-50%,-100%);white-space:nowrap;color:#fff7dc;background:#40352ad9;border:1px solid #edd595;border-radius:12px;padding:4px 8px;font:600 10px/1 system-ui;letter-spacing:.05em}.tower.chosen:not(.dead) .badge{display:inline-flex;align-items:center;gap:4px}.badge svg{width:12px;height:12px}.tower.hit .body{animation:jolt .25s ease-out}.tower.dead{pointer-events:none}.tower.dead .body{visibility:hidden}.tower .rubble{position:absolute;bottom:-2%;width:100%;height:22%;left:0;display:none;overflow:hidden;clip-path:polygon(0 80%,8% 48%,18% 61%,30% 32%,37% 39%,47% 8%,58% 50%,74% 30%,83% 55%,92% 57%,100% 100%,0 100%)}.tower.dead .rubble{display:block}.rubble img{position:absolute;bottom:0;filter:brightness(.69) saturate(.63)}.shard{position:absolute;inset:0;pointer-events:none;overflow:hidden;animation:collapse .72s cubic-bezier(.48,.05,.84,.38) forwards;transform-origin:50% 88%}.shard img{width:100%}.shard.a{clip-path:polygon(0 0,47% 0,40% 28%,50% 48%,33% 70%,44% 100%,0 100%);--dx:-18%;--roll:-16deg}.shard.b{clip-path:polygon(47% 0,100% 0,100% 38%,62% 57%,50% 48%,40% 28%);--dx:13%;--roll:14deg}.shard.c{clip-path:polygon(100% 38%,100% 100%,44% 100%,33% 70%,50% 48%,62% 57%);--dx:7%;--roll:8deg}@keyframes collapse{0%{opacity:1}70%{opacity:.95}100%{transform:translate(var(--dx),43%) rotate(var(--roll));opacity:0}}@keyframes jolt{30%{transform:translateX(2%) rotate(1.2deg)}70%{transform:translateX(-1%)}}


.sky-gate { position: absolute; transform: translate(-50%, -50%); width: clamp(75px, 9.6%, 138px); z-index: 6; }
#gate2 { left: 43%; top: 40%; }
#gate5 { left: 57%; top: 23%; width: clamp(68px, 8.6%, 128px); }
.console {
  position: relative; display: flex; gap: 22px; align-items: center; min-height: 78px;
  padding: 12px 21px; border-top: 2px solid #aa9265;
  background: linear-gradient(105deg, #253f41 0%, #19353a 50%, #2a3f3d 100%); box-shadow: inset 0 1px #e5dfb33d;
}
.readout { gap: 10px; min-width: 161px; }
.dial { flex: none; width: 36px; height: 36px; color: #ddbf80; }
.kicker { display: block; color: #bdc7b3; font-size: 10px; font-weight: 500; line-height: 1.3; letter-spacing: .13em; margin-bottom: 4px; }
.readout strong { display: block; white-space: nowrap; font: 700 19px/1.05 "Songti SC", STSong, SimSun, serif; color: #f6e7c7; }
.readout b { color: #b9eadc; font: 700 17px/1 Georgia, serif; }
.status { display: grid; align-content: center; gap: 4px; margin: 0; border-left: 1px solid #b7be9c4d; padding-left: 21px; font-size: 14px; line-height: 1.35; color: #f1e9d1; }
.status span + span { color: #bbcbc0; font-size: 12px; }
#fire {
  flex: none; gap: 9px; justify-content: center; margin-left: auto; min-width: 138px; min-height: 46px;
  padding: 7px 14px;
  color: #322715; background: linear-gradient(175deg, #ffe6ac, #e8ba70 59%, #d8a260);
  border: 1px solid #fff0b4; border-radius: 7px;
  box-shadow: 0 2px 0 #815c36, inset 0 0 0 2px #dab06d, inset 0 0 0 3px #f7dc98;
  font-weight: 800; font-size: 19px; line-height: 1.2; letter-spacing: .08em;
}
#fire:hover:not(:disabled) { filter: brightness(1.05); }
#fire:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px #805b37, inset 0 0 0 2px #d5aa66; }
#fire:disabled { filter: saturate(.6); opacity: .84; }
kbd { border: 1px solid #755b397a; padding: 3px; font: 500 10px/1 system-ui; border-radius: 3px; letter-spacing: 0; }
@media (max-width: 900px) {
  .shell { padding: 5px 10px 12px; }
  .mast { gap: 14px; min-height: 54px; }
  .battle-settings { padding-left: 12px; }
  .console { gap: 14px; padding: 10px 13px; }
  .readout { min-width: 132px; }
  .status { padding-left: 13px; font-size: 13px; }
  #fire { min-width: 110px; }
}
@media (max-width: 680px) {
  body { display: block; }
  .shell { width: 100%; margin: 0 auto; padding: max(4px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .mast { display: grid; grid-template-columns: 1fr auto; gap: 4px 6px; min-height: 0; padding: 2px 3px 7px; }
  .brand { gap: 6px; }
  .crest { width: 30px; height: 34px; }
  h1 { font-size: 25px; letter-spacing: .08em; }
  .tools { grid-column: 2; grid-row: 1; gap: 5px; }
  .tools button { min-height: 34px; width: 34px; }
  .tools .icon { width: 18px; height: 18px; }
  .battle-settings { grid-column: 1 / -1; grid-row: 2; border: 0; padding: 0; gap: 6px; }
  .setting { justify-content: flex-start; min-width: 0; min-height: 34px; padding: 0 9px; font-size: 12px; }
  .setting .setting-icon { width: 14px; height: 14px; }
  .setting .swap { width: 12px; }
  .frame { border-radius: 7px; }
  .field { aspect-ratio: 1.045; }
  .huds { top: 2.6%; left: 2.5%; right: 2.5%; gap: 10px; }
  .faction { gap: 4px; padding: 4px 5px 5px 3px; border-left-width: 2px; }
  .faction.sun { padding: 4px 3px 5px 5px; border-right-width: 2px; }
  .sigil { width: 23px; height: 23px; }
  .sigil .icon { width: 16px; height: 16px; }
  .team { margin-right: 3px; font-size: 10px; letter-spacing: 0; }
  .faction strong { font-size: 13px; letter-spacing: .02em; }
  .pips { gap: 1px; margin-top: 4px; }
  .pips i { width: 4px; height: 3px; }
  .sky-gate { width: 17.5%; min-width: 57px; }
  #gate2 { left: 39%; top: 37%; }
  #gate5 { left: 63%; top: 24%; width: 16%; }
  .tower .badge { font-size: 9px; top: -4px; padding: 3px 4px; }
  .corn { width: 15px; height: 15px; }
  .console { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 7px; padding: 9px 10px; }
  .readout { min-width: 0; gap: 7px; }
  .readout strong { font-size: 17px; }
  .readout b { font-size: 15px; }
  .dial { width: 28px; height: 28px; }
  .kicker { font-size: 10px; margin-bottom: 2px; }
  .status { grid-column: 1/-1; grid-row: 2; display: flex; flex-wrap: wrap; gap: 2px 12px; border-left: 0; border-top: 1px solid #b5b99a41; padding: 6px 0 0; font-size: 12px; }
  .status span + span { font-size: 11px; }
  #fire { grid-column: 2; grid-row: 1; min-width: 100px; min-height: 42px; font-size: 17px; }
  kbd { display: none; }
}
@media (min-width: 681px) and (orientation: landscape) and (max-height: 510px) {
  .shell { width: min(100%, calc((100svh - 88px) * 2.12 + 12px)); padding: 1px 5px 3px; }
  .mast { min-height: 36px; padding-bottom: 2px; }
  .crest { width: 23px; height: 27px; }
  h1 { font-size: 19px; }
  .tools button, .setting { min-height: 29px; }
  .tools button { width: 29px; }
  .field { aspect-ratio: 2.12; }
  .console { min-height: 43px; padding: 3px 9px; }
  .kicker, .dial, kbd { display: none; }
  .readout strong { font-size: 14px; }
  #fire { min-height: 32px; font-size: 14px; }
  .huds { top: 2%; }
  .sigil { width: 21px; height: 21px; }
  .faction strong { font-size: 11px; }
  .team { font-size: 9px; }
  .status span + span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tower.hit .body { animation: none; }
  .shard { display: none; }
}
