:root {
  color-scheme: light;
  --ink: #292339;
  --muted: #696278;
  --purple: #6547ba;
  --stroke: #d9d4e4;
  --paper: #fff;
  --page: #f7f6fb;
  font-family: "Malgun Gothic","Apple SD Gothic Neo",Inter,system-ui,sans-serif;
  color: var(--ink);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .57;
}

button:focus-visible,input:focus-visible {
  outline: 3px solid #895feb;
  outline-offset: 3px;
}

[hidden] {
  display: none!important;
}

.wrap {
  width: min(1920px,96%);
  margin: auto;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--stroke);
}

.nav {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 900;
  letter-spacing: -1.2px;
  font-size: 20px;
}

.brand-mark {
  height: 36px;
  width: 36px;
  display: grid;
  place-items: center;
  background: #eee8ff;
  border: 1px solid #cec1eb;
  border-radius: 11px;
  transform: rotate(-4deg);
}

.brand-mark img {
  height: 30px;
}

.quiet,.primary,.secondary {
  border-radius: 10px;
  font-weight: 750;
  transition: filter .15s,transform .15s;
}

.quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
  padding: 8px 13px;
  font-size: 13px;
}

.quiet span {
  margin-left: 5px;
}

.quiet:hover,.secondary:hover {
  background: #eeebf5;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 4px 20px;
}

.phase {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--purple);
  font-weight: 750;
  font-size: 13px;
}

.phase i,.live-dot {
  width: 8px;
  height: 8px;
  background: #8c65d2;
  display: inline-block;
  border-radius: 50%;
}

h1 {
  font-size: clamp(38px,5vw,64px);
  line-height: 1.12;
  letter-spacing: -.085em;
  margin: 9px 0 8px;
  font-weight: 900;
}

h1 span {
  color: #9463da;
}

.intro p,.panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  font-size: 14px;
}

.mascot {
  margin-right: 27px;
  position: relative;
  transform: rotate(6deg);
}

.mascot img {
  width: 80px;
  filter: drop-shadow(0 5px 0 #d8cfe5);
}

.mascot span {
  font-size: 62px;
}

.mascot b,.mascot i {
  position: absolute;
  color: #aa82df;
  font-style: normal;
}

.mascot b {
  left: -19px;
  top: 18px;
  font-size: 21px;
}

.mascot i {
  right: -16px;
  bottom: 14px;
  font-size: 28px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 12px;
}

.in-round .intro {
  display: none;
}

.in-round .nav {
  height: 40px;
}

.in-round .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.in-round .brand-mark img {
  height: 24px;
}

.in-round .layout {
  /* Keep the full canvas visible when viewport height limits its width. */
  width: min(100%,calc((100dvh - 90px) * 16 / 9));
  margin: 7px auto 0;
}

.in-round .arena-panel {
  grid-row: 1;
}

.arena-panel,.panel {
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: 0 4px 0 #31233b09;
}

.arena-panel {
  overflow: hidden;
}

.arena-head,.arena-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
}

.in-round .arena-head {
  padding-block: 5px;
}

.arena-head strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  font-size: 15px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #70bc93;
}

.meter,.timer {
  font-size: 13px;
  white-space: nowrap;
}

.meter span,.meter small {
  color: var(--muted);
  font-size: 12px;
}

.meter b,.timer b {
  font-variant-numeric: tabular-nums;
}

.timer {
  background: #f4f1fa;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 7px;
  padding: 5px 8px;
}

.clock-icon {
  width: 12px;
  height: 12px;
  border: 1.5px solid #74658b;
  border-radius: 100%;
  position: relative;
}

.clock-icon:after {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 3px;
  height: 4px;
  border-left: 1px solid #74658b;
  border-bottom: 1px solid #74658b;
}

.stage {
  background: #eee8f7;
  border-block: 1px solid var(--stroke);
  position: relative;
}

.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  touch-action: none;
}

.stage.interactive canvas {
  cursor: none;
}

.arena-foot {
  justify-content: space-between;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-height: 44px;
}

.panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 15px;
}

h2 {
  font-size: 17px;
  letter-spacing: -.055em;
  margin: 0 0 15px;
}

.weapon-list,.actions,#card-list {
  gap: 9px;
}

#weapons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

#weapons h2 {
  margin: 0;
  font-size: 14px;
}

#round-settings,#start-settings {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

#round-settings legend,#start-settings legend {
  padding: 0;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 750;
}

.duration-inputs,.duration-inputs label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.duration-inputs label {
  gap: 4px;
}

.duration-inputs input {
  width: 50px;
  min-height: 32px;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  padding: 5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

#start-settings label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

#auto-start {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--purple);
  flex: none;
}

#start-settings label:has(input:disabled) {
  color: var(--muted);
  cursor: default;
}

#duration-error {
  margin-top: 4px;
  color: #8b3456;
  font-size: 12px;
}

.weapon-list {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
}

.weapon {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--stroke);
  color: var(--ink);
  border-radius: 12px;
  padding: 7px 9px;
  width: 100%;
}

.weapon[aria-pressed=true] {
  background: #f3edff;
  border-color: #9b7bce;
  box-shadow: inset 0 0 0 1px #ac8edb;
}

.weapon-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  position: relative;
  flex: none;
}

.hammer-art {
  background: #e6d8ff;
}

.hammer-art i,.hammer-art b {
  position: absolute;
  display: block;
  transform: rotate(37deg);
  border: 1.5px solid #5e3b78;
}

.hammer-art i {
  background: #f2b46c;
  width: 7px;
  height: 23px;
  left: 15px;
  top: 13px;
  border-radius: 4px;
}

.hammer-art b {
  width: 25px;
  height: 13px;
  left: 11px;
  top: 8px;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg,#ad72cc 0 3px,#e2b1eb 3px 6px);
}

.fire-art {
  background: #fff0d9;
  font-size: 23px;
}

.weapon strong,.weapon small {
  display: block;
}

.weapon strong {
  font-size: 15px;
  letter-spacing: -.04em;
}

.weapon small {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.weapon em {
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #cfc8d9;
  margin-left: auto;
}

.weapon[aria-pressed=true] em {
  background: var(--purple);
  border-color: var(--purple);
}

.weapon[aria-pressed=true] em:after {
  content: "";
  width: 6px;
  height: 3px;
  transform: rotate(-45deg);
  border-left: 1.5px solid white;
  border-bottom: 1.5px solid white;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  margin-left: auto;
}

.actions:not(:has(>button:not([hidden]))) {
  display: none;
}

.primary,.secondary {
  padding: 11px 14px;
  font-size: 14px;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: white;
  border: 1px solid #583e9a;
  background: var(--purple);
  box-shadow: 0 2px 0 #493082;
}

.primary:hover {
  filter: brightness(1.08);
}

.primary:active {
  transform: translateY(1px);
}

.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

#progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

#card-meter {
  accent-color: #8863d2;
  width: clamp(48px,12vw,144px);
  height: 8px;
}

.caught-number {
  color: var(--ink);
  white-space: nowrap;
}

.caught-number b {
  font-size: 15px;
  margin-right: .2em;
}

.in-round #count-info {
  display: none;
}

.panel #peers,.panel #status,.panel #auto-status {
  font-size: 12px;
}

#auto-status {
  color: var(--purple);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

#room {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.room-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.room-code b {
  background: #f4f0fa;
  border-radius: 6px;
  font-family: ui-monospace,monospace;
  font-size: 16px;
  letter-spacing: .12em;
  padding: 7px 9px;
}

.arena-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: safe center;
  justify-items: center;
  overflow: auto;
  padding: clamp(8px,2vw,28px);
  background: #2e204da8;
}

.upgrade-picker {
  width: min(100%,750px);
}

.upgrade-picker h2 {
  margin-bottom: clamp(6px,1.6vw,20px);
  color: #fff;
  font-size: clamp(15px,2.2vw,30px);
  text-align: center;
  text-shadow: 0 2px 4px #211633;
}

#card-list {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: clamp(5px,1.5vw,18px);
  padding: 4px;
}

.card-option {
  --card-fill: #f3ebff;
  --card-ink: #463174;
  --card-edge: #ae8cde;
  display: grid;
  min-width: 0;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(3px,0.75vw,9px);
  padding: clamp(5px,1.3vw,18px);
  border: 1px solid var(--card-edge);
  border-radius: clamp(8px,1.2vw,16px);
  box-shadow: 0 4px 0 var(--card-edge),0 8px 16px #21163355;
  color: var(--card-ink);
  background: linear-gradient(#fff,var(--card-fill));
  line-height: 1.2;
  text-align: left;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.card-option:nth-child(2) {
  --card-fill: #e6f6f3;
  --card-ink: #235952;
  --card-edge: #72b6a9;
}

.card-option:nth-child(3) {
  --card-fill: #fff1d6;
  --card-ink: #75461e;
  --card-edge: #d8a655;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: clamp(1px,.5vw,6px);
}

.card-symbol {
  width: clamp(23px,4vw,50px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: clamp(6px,1vw,12px);
  background: var(--card-fill);
  font-size: clamp(15px,2.7vw,30px);
}

.card-symbol svg {
  display: block;
  width: 64%;
  height: 64%;
}

.card-option kbd {
  border: 1px solid var(--card-edge);
  background: #fff;
  border-radius: 5px;
  padding: 2px .5em;
  font-size: clamp(9px,1vw,13px);
}

.card-title {
  align-self: start;
  font-size: clamp(12px,1.75vw,22px);
  letter-spacing: -.035em;
}

.card-stat {
  color: #5d536b;
  font-size: clamp(10px,1.1vw,13px);
  font-weight: 650;
}

.card-values {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px clamp(2px,.55vw,8px);
  padding-top: clamp(4px,.7vw,8px);
  border-top: 1px solid var(--card-edge);
  font-size: clamp(10px,1.3vw,18px);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}

.card-current {
  color: #5d536b;
}

.card-arrow {
  font-size: .9em;
}

.card-next {
  font-size: 1.05em;
}

.card-option:hover {
  box-shadow: 0 4px 0 var(--card-edge),0 0 0 2px var(--card-edge),0 8px 16px #21163355;
}

.card-option:focus-visible {
  outline-color: #fff;
}

.result-summary {
  width: min(100%,360px);
  padding: clamp(12px,2.3vw,32px);
  border: 1px solid #c7afd9;
  border-radius: 16px;
  box-shadow: 0 5px 0 #21163355;
  background: var(--paper);
  text-align: center;
}

.result-summary h2 {
  margin-bottom: 6px;
  font-size: clamp(20px,3vw,42px);
}

.result-summary p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(13px,1.2vw,16px);
}

.panel #status {
  flex-basis: 100%;
  color: #664a81;
  overflow-wrap: anywhere;
}

footer {
  color: #746b83;
  font-size: 12px;
  margin: 18px 3px 26px;
}

.round-info {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.round-info i {
  color: #b0a6bf;
  font-style: normal;
}

.round-info span {
  padding-left: 9px;
  border-left: 1px solid var(--stroke);
}

.credits {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
  line-height: 1.6;
}

.credits h2, .credits p {
  margin: 2px 0;
  font-size: inherit;
}

.credits a {
  color: var(--purple);
  text-underline-offset: 2px;
}

dialog {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 24px;
  color: var(--ink);
  width: min(360px,90vw);
}

dialog::backdrop {
  background: #25193266;
}

dialog label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

dialog input {
  width: 100%;
  border: 1px solid #b6a7c6;
  border-radius: 8px;
  padding: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media(max-width:900px) {
  .wrap {
    width: calc(100% - 24px);
  }
  .intro {
    padding: 24px 0;
  }
  .arena-head,.arena-foot {
    padding: 11px;
  }
  .weapon {
    gap: 7px;
  }
  .mascot {
    margin-right: 10px;
  }
}

@media(max-width:700px) {
  .intro {
    padding: 19px 3px;
  }
  .mascot img {
    width: 59px;
  }
  .nav {
    height: 56px;
  }
  .panel #weapons,.panel .actions {
    width: 100%;
  }
  .weapon-list {
    flex: 1 0 100%;
  }
  .actions button {
    flex: 1 1 auto;
  }
  .arena-head {
    gap: 8px;
  }
  .arena-foot {
    font-size: 10px;
  }
  .intro p {
    font-size: 12px;
  }
}

@media(max-width:390px) {
  .mascot {
    display: none;
  }
  .weapon-icon {
    width: 32px;
  }
  .weapon {
    padding: 8px;
  }
  .weapon em {
    display: none;
  }
}

@media(max-width:350px) {
  #upgrades {
    padding: 4px;
  }

  .upgrade-picker h2 {
    margin-bottom: 3px;
    font-size: 14px;
    line-height: 1.1;
  }

  .card-option {
    gap: 2px;
    padding: 4px;
  }

  .card-heading {
    margin-bottom: 0;
  }

  .card-symbol {
    width: 22px;
  }

  .card-title,.card-stat {
    line-height: 1.1;
    word-break: normal;
  }

  .card-title {
    font-size: 11px;
  }

  .card-values {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1px 4px;
  }

  .card-current {
    grid-area: 1/2;
  }

  .card-arrow {
    grid-area: 2/1;
    transform: rotate(90deg);
  }

  .card-next {
    grid-area: 2/2;
  }
}
