/* AaCute everywhere. The installed copy is used when there is one. */
@font-face {
  font-family: "TankCute";
  src: local("AaCute Regular"), local("AaCute"), url("fonts/AaCute-ui.woff2") format("woff2");
  font-display: swap;
}

:root {
  --font: "TankCute", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --ink: #161616;
  --muted: #666;
  --line: #cfcfcf;
  --soft: #f2f2f2;
  --go: #a9e5a3;
  --go-hover: #97dc90;
  --danger: #c8302c;
  --numbers: var(--font);
}

/* One size knob: everything below is in rem and follows the window. */
html { font-size: clamp(14px, min(1.05vw, 1.85vh), 22px); }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2563c9; outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 3rem;
  padding: 0 1.25rem;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: .4rem;
  box-shadow: 0 .25rem 0 rgba(0, 0, 0, .28);
  transition: transform .08s, box-shadow .08s, background-color .12s;
}
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:active:not(:disabled) { transform: translateY(.2rem); box-shadow: none; }
.btn:disabled { cursor: default; opacity: .45; }
.btn.primary { background: var(--go); }
.btn.primary:hover:not(:disabled) { background: var(--go-hover); }
.btn.danger { color: var(--danger); }
.btn.tall { height: 3.75rem; font-size: 1.2rem; }
.btn.small { height: 2.4rem; padding: 0 1rem; font-size: .9rem; }

/* ---------------------------------------------------------------- screens */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow: auto;
  padding: 1.25rem;
}
.screen.show { display: flex; }
.screen > * { margin: auto; }
.screen.veil { background: rgba(255, 255, 255, .72); }

/* ---------------------------------------------------------------- cover */

/* A fixed 1000 x 564 stage; everything inside is sized relative to its width. */
.cover {
  position: relative;
  flex: none;
  width: min(100%, calc((100vh - 2.5rem) * 1000 / 564));
  aspect-ratio: 1000 / 564;
  container-type: inline-size;
}
.art { position: absolute; inset: 0; width: 100%; height: 100%; }

.tag {
  position: absolute;
  width: 21cqw;
  min-height: 5.8cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 2.7cqw;
  line-height: 1.15;
  white-space: nowrap;
  background: #fff;
  border: .5cqw solid var(--ink);
  border-right-width: .75cqw;
  box-shadow: 0 .65cqw 0 rgba(0, 0, 0, .3);
  translate: -50% -50%;
  transform: rotate(var(--tilt)) skewX(var(--lean));
  transition: scale .12s, background-color .12s;
}
.tag small { font-size: 1.75cqw; }
.tag em {
  position: absolute;
  top: calc(100% + .7cqw);
  left: 50%;
  translate: -50% 0;
  display: none;
  width: 19cqw;
  padding: .6cqw .4cqw;
  font-style: normal;
  font-weight: 700;
  font-size: 1.5cqw;
  line-height: 1.35;
  white-space: normal;
  background: var(--soft);
  border: .3cqw solid var(--ink);
  pointer-events: none;
}
.tag:hover, .tag:focus-visible { background: var(--go); scale: 1.14; z-index: 3; }
.tag:hover em, .tag:focus-visible em { display: block; }
/* The upper row explains itself above, so it never covers the row underneath. */
.t1 em, .t2 em, .t3 em { top: auto; bottom: calc(100% + .7cqw); }
.t1 { left: 23.5%; top: 59%; --tilt: 2.5deg; --lean: -5deg; }
.t2 { left: 51%; top: 53%; --tilt: 1.5deg; --lean: 3deg; }
.t3 { left: 78%; top: 59%; --tilt: 3deg; --lean: 5deg; }
.t4 { left: 23.5%; top: 72%; --tilt: -2deg; --lean: -3deg; }
.t5 { left: 50.5%; top: 67.5%; --tilt: 2deg; --lean: 4deg; }
.t6 { left: 78%; top: 72%; --tilt: -1.5deg; --lean: 3deg; }

.cover h1 {
  position: absolute;
  left: 50%;
  top: 85.5%;
  translate: -50% -50%;
  font-size: 8.6cqw;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
  text-shadow: .55cqw .55cqw 0 #bcbcbc;
  pointer-events: none;
}
.speaker {
  position: absolute;
  left: 1.5%;
  bottom: 3%;
  width: 4.6cqw;
  height: 4.6cqw;
  background: none;
  border: 0;
}
.speaker svg { width: 100%; height: 100%; }
.speaker .off { display: none; }
.speaker.muted .on { display: none; }
.speaker.muted .off { display: inline; }
.corner { position: absolute; right: 1.5%; bottom: 3.5%; display: flex; gap: 1.8cqw; }
.corner button {
  font-weight: 700;
  font-size: 1.55cqw;
  color: #555;
  background: none;
  border: 0;
  border-bottom: .2cqw solid #999;
}
.corner button:hover { color: var(--ink); border-color: var(--ink); }
.legal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: .2%;
  font-size: max(10px, 1.1cqw);
  text-align: center;
  color: #999;
}

/* ---------------------------------------------------------------- dialogs */

.card {
  width: min(33rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.6rem;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: .8rem;
  box-shadow: 0 .55rem 0 rgba(0, 0, 0, .18);
}
.card.narrow { width: min(25rem, 100%); }
.card.wide { width: min(44rem, 100%); }
.card.center { text-align: center; }
h2 { font-size: 1.65rem; font-weight: 900; text-align: center; letter-spacing: .08em; text-shadow: 2px 2px 0 #cfcfcf; }

.form { display: flex; flex-direction: column; gap: .7rem; }
.field { display: grid; grid-template-columns: 5.5rem 1fr; align-items: center; gap: .75rem; }
.field label { font-size: .95rem; font-weight: 700; }
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: .4rem;
}
.seg button {
  height: 2.4rem;
  font-size: .92rem;
  white-space: nowrap;
  background: #fff;
  border: 0;
  border-left: 1px solid var(--line);
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--soft); }
.seg button.on { background: var(--go); font-weight: 700; }
select {
  width: 100%;
  height: 2.75rem;
  padding: 0 .8rem;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: .4rem;
}
.note { font-size: .85rem; line-height: 1.65; color: var(--muted); }

.actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .75rem; }
.actions.stack { grid-auto-flow: row; }
#pause-body .btn { width: 100%; }

.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.join { display: grid; grid-template-columns: 1fr auto; gap: .75rem; }
.join input {
  min-width: 0;
  height: 3rem;
  padding: 0 .75rem;
  text-align: center;
  font: 700 1.35rem var(--numbers);
  letter-spacing: .25em;
  border: 2px solid var(--ink);
  border-radius: .4rem;
  user-select: text;
}
.join input::placeholder { font-size: .95rem; letter-spacing: 0; font-weight: 400; }
.error { min-height: 1.3rem; text-align: center; font-size: .88rem; color: var(--danger); }

.room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.15rem;
  background: var(--soft);
  border: 2px solid var(--ink);
  border-radius: .4rem;
}
.room span { display: block; font-size: .8rem; color: var(--muted); }
.room strong { font: 700 2.5rem var(--numbers); letter-spacing: .18em; user-select: text; }

.players { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.player {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .45rem .9rem;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: .4rem;
}
.player b { display: block; font-size: .98rem; }
.player span { font-size: .8rem; color: var(--muted); }
#end-icon .tank-icon { margin: 0 auto; }

/* ---------------------------------------------------------------- stepper and colours */

.limit { display: grid; grid-template-columns: 2.6rem 1fr 2.6rem 4.5rem; gap: .4rem; }
.limit button, .limit input {
  height: 2.5rem;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: .4rem;
}
.limit button { font-size: 1.15rem; }
.limit button:hover { background: var(--soft); }
.limit button.free { font-size: .92rem; }
.limit button.on { background: var(--go); }
.limit input { min-width: 0; text-align: center; font-size: 1.15rem; user-select: text; appearance: textfield; }
.limit input::-webkit-inner-spin-button { appearance: none; }
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch {
  width: 2.1rem;
  height: 2.1rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 0 0 0 #fff;
}
.swatch.on { box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px var(--ink); }
.swatch:disabled { opacity: .18; cursor: default; }

/* ---------------------------------------------------------------- help */

.help { width: min(48rem, 100%); gap: .9rem; }
.help h3 { font-size: 1.1rem; }
.how { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.how section { border: 2px solid var(--ink); border-radius: .5rem; overflow: hidden; }
.how h3 { padding: .3rem .8rem; background: var(--go); border-bottom: 2px solid var(--ink); }
.how p { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .22rem .8rem; }
.card.help { width: min(57rem, 100%); }
.help .weapons { grid-template-columns: repeat(4, 1fr); gap: .45rem; }
@media (max-width: 760px) { .help .weapons { grid-template-columns: 1fr 1fr; } }
.help .weapons li { padding: .45rem .55rem; gap: .55rem; }
.help .btn { flex: none; height: 2.6rem; }
.how p span { margin-left: .35rem; font-size: .85rem; color: var(--muted); }
kbd {
  min-width: 1.9rem;
  padding: .15rem .5rem;
  font-family: var(--font);
  font-size: .85rem;
  text-align: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-bottom-width: 4px;
  border-radius: .35rem;
}
.rules {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem 1rem;
  padding: .7rem .9rem;
  font-size: .88rem;
  line-height: 1.5;
  background: var(--soft);
  border-radius: .5rem;
}
.rules li { display: flex; gap: .5rem; }
.rules li::before { content: "●"; font-size: .55rem; line-height: 2.4; }

.weapons, #achievement-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: .6rem;
}
.weapons li {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .55rem .65rem;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--muted);
  border: 2px solid var(--line);
  border-radius: .5rem;
}
.weapons canvas { width: 2.4rem; height: 2.4rem; flex: none; }
.weapons b { display: block; font-size: .95rem; color: var(--ink); }
#achievement-list li {
  padding: .65rem .85rem;
  border: 2px dashed var(--line);
  border-radius: .4rem;
  font-size: .8rem;
  color: var(--muted);
}
#achievement-list li.got { border: 2px solid var(--ink); background: #eefbec; color: var(--ink); }
#achievement-list b { display: block; font-size: .95rem; }

/* ---------------------------------------------------------------- in game */

#topbar, #scorebar { position: fixed; left: 0; right: 0; display: none; padding: .7rem 1rem; }
body.in-game #topbar { display: grid; }
body.in-game #scorebar { display: flex; }
#topbar { top: 0; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; }
#topbar > .btn { justify-self: start; }
.chips { display: flex; gap: .5rem; align-items: center; justify-content: center; }
.chips.right { justify-content: flex-end; }
.chip { padding: .35rem .85rem; border-radius: 2rem; font-size: .85rem; background: var(--soft); color: #444; white-space: nowrap; }
.chip.strong { color: var(--ink); font-weight: 700; }

/* Tanks and big scores along the bottom, as in the classic game. */
#scorebar { bottom: 0; justify-content: center; flex-wrap: wrap; gap: 1.5rem; }
.score-card {
  width: 14rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .3rem .6rem;
  padding: .3rem .5rem;
  transition: opacity .25s;
}
.score-card.dead { opacity: .32; }
.score-info { min-width: 0; }
.score-info b { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-weapon { display: block; min-height: 1.1rem; font-size: .72rem; color: var(--muted); }
.score-card strong { font: 700 2.5rem var(--numbers); min-width: 1.8rem; text-align: right; }
.ammo, .pips { display: flex; gap: .22rem; }
.ammo i { width: .45rem; height: .45rem; border-radius: 50%; background: #dcdcdc; }
.ammo i.on { background: var(--ink); }
.pips { grid-column: 1 / -1; }
.pips i { flex: 1; height: .26rem; border-radius: 1rem; background: #e4e4e4; }
.pips i.on { background: var(--team); }

#toasts {
  position: fixed;
  top: 4rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
  pointer-events: none;
  z-index: 5;
}
.toast {
  max-width: 20rem;
  padding: .6rem 1rem;
  border-radius: .5rem;
  color: #fff;
  font-size: .8rem;
  background: #2a2a2a;
  transition: opacity .4s, transform .4s;
}
.toast b { display: block; font-size: .92rem; }
.toast.gone { opacity: 0; transform: translateX(1.5rem); }

@media (max-width: 560px) {
  .how, .rules { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr; gap: .3rem; }
  #topbar { grid-template-columns: auto 1fr auto; }
  .score-card { width: 11.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
