:root {
  --bg: #0f1318;
  --ink: #e8edf3;
  --dim: #8a96a6;
  --panel: rgba(12, 16, 22, 0.72);
  --hp: #5ad17a;
  --ar: #f2c84b;
  --hot: #ff6b4a;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.3 system-ui, "Noto Sans TC", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.status {
  display: grid;
  gap: 5px;
  background: var(--panel);
  padding: 7px 10px;
  border-radius: 10px;
}
#clock {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bar {
  position: relative;
  width: 118px;
  height: 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  transition: width 0.12s;
}
.hp i {
  background: var(--hp);
}
.ar i {
  background: var(--ar);
}
.bar b {
  position: relative;
  display: block;
  font-size: 11px;
  line-height: 14px;
  padding-left: 6px;
  color: #0b0e12;
  mix-blend-mode: normal;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}
#board {
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  background: var(--panel);
  border-radius: 10px;
  display: grid;
  gap: 3px;
  min-width: 78px;
}
#board li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
#board li.me {
  font-weight: 700;
}
#board .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
#board .n {
  margin-left: auto;
}
#edge {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 70px 18px rgba(255, 45, 35, 0.8);
  opacity: 0;
}
#verdict {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
#verdict:empty {
  display: none;
}
#toast {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 104px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#toast.on {
  opacity: 1;
}
#stick {
  position: absolute;
  width: 116px;
  height: 116px;
  margin: -58px 0 0 -58px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  left: 92px;
  top: calc(100% - 96px - env(safe-area-inset-bottom));
  opacity: 0.35;
}
#stick.on {
  opacity: 1;
}
#stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}
#fire {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 140, 110, 0.9);
  background: radial-gradient(circle, rgba(255, 107, 74, 0.55), rgba(255, 107, 74, 0.25));
  pointer-events: auto;
  touch-action: none;
}
#fire::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
}
#fire.on {
  background: rgba(255, 107, 74, 0.8);
}
.weapons {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(260px, 62vw);
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 108px);
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.weapons button {
  min-width: 48px;
  color: var(--c);
  padding: 5px 6px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--panel);
  display: grid;
  justify-items: center;
  font-size: 13px;
  line-height: 1.15;
}
.weapons button canvas {
  position: static;
  width: 36px;
  height: 18px;
}
.weapons button b {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.weapons button.cur {
  border-color: var(--c);
  background: rgba(40, 48, 60, 0.9);
}
.weapons button.cur b {
  color: var(--ink);
}
.weapons button:disabled {
  opacity: 0.3;
}
.sheet {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: safe center;
  justify-items: center;
  gap: 16px;
  overflow-y: auto;
  background: rgba(10, 13, 17, 0.9);
  padding: 16px;
  touch-action: pan-y;
}
.sheet[hidden],
.sheet [hidden] {
  display: none !important;
}
.sheet h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 0.2em;
}
#result {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  min-width: 220px;
}
#result:empty {
  display: none;
}
#result li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}
#result li.me {
  outline: 1px solid var(--ink);
}
#result .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
#result .n {
  margin-left: auto;
  font-weight: 700;
}
#result .d {
  color: var(--dim);
  font-size: 13px;
}
#start,
#again {
  padding: 12px 44px;
  border-radius: 999px;
  border: 0;
  background: var(--hot);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.keys {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}
@media (pointer: coarse) {
  .keys {
    display: none;
  }
}

.row {
  display: flex;
  gap: 10px;
}
.seg {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.seg button {
  padding: 9px 20px;
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 15px;
}
.seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 700;
}
.opts {
  display: flex;
  gap: 8px;
}
.opts button {
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.opts button:disabled {
  color: var(--dim);
  border-color: rgba(255, 255, 255, 0.1);
}
@media (max-width: 480px) {
  .seg button {
    padding: 9px 12px;
  }
}
#demo,
#stats,
#mute,
#back,
#home {
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: none;
  font-size: 15px;
}
#mute {
  color: var(--dim);
}
.side {
  display: grid;
  gap: 6px;
  justify-items: end;
}
#feed {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
  justify-items: end;
  font-size: 13px;
}
#feed li {
  background: var(--panel);
  padding: 3px 8px;
  border-radius: 6px;
}
#feed span {
  color: var(--dim);
  margin: 0 3px;
}
#stop {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--panel);
  pointer-events: auto;
}
.demo #stop {
  display: block;
}
.demo #fire,
.demo #stick,
.demo .weapons {
  opacity: 0.25;
  pointer-events: none;
}

#powers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
#powers:empty {
  display: none;
}
#powers i {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: 6px;
  padding: 0 5px;
  font-variant-numeric: tabular-nums;
}

/* The menu's views: home, tournament, your record, the result. */
.list {
  display: grid;
  gap: 10px;
  width: min(320px, 100%);
}
.list button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  font-size: 17px;
  font-weight: 700;
  text-align: left;
}
.list button span {
  margin-left: auto;
  color: var(--dim);
  font-size: 14px;
  font-weight: 400;
}
.list button b {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.list button.now {
  border-color: var(--hot);
}
.list button:disabled {
  opacity: 0.35;
}
#stages button {
  font-size: 15px;
  padding: 11px 16px;
}
#stages button span {
  color: var(--hp);
}
#earned {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  color: var(--dim);
}
#earned:empty {
  display: none;
}
#earned b {
  color: var(--ar);
}
#profile {
  display: grid;
  gap: 14px;
  width: min(360px, 100%);
}
#profile .col {
  display: grid;
  gap: 12px;
  justify-items: center;
  align-content: start;
}
#profile p {
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#totals {
  font-weight: 700;
}
#medals,
#hint {
  color: var(--dim);
  font-size: 13px;
}
#medals:empty {
  display: none;
}
#hint {
  min-height: 1.3em;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.chips:empty {
  display: none;
}
.chips i,
.chips button {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: none;
  font-style: normal;
  font-size: 13px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.chips i {
  color: var(--c);
}
.chips button.got {
  color: var(--ar);
  border-color: var(--ar);
}
.seg .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}
.seg button.locked {
  opacity: 0.4;
}

/* A phone held sideways: little height, so the board lies flat and the
   weapons sit beside the fire button. */
@media (orientation: landscape) and (max-height: 500px) {
  .sheet {
    gap: 10px;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  .sheet h1 {
    font-size: 28px;
  }
  #stages {
    grid-template-columns: 1fr 1fr;
    width: min(620px, 100%);
  }
  #profile {
    grid-template-columns: 1fr 1fr;
    width: min(740px, 100%);
  }
  #result {
    grid-template-columns: 1fr 1fr;
  }
  #result li {
    padding: 5px 12px;
  }
  .top {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }
  #board {
    display: flex;
    gap: 12px;
    min-width: 0;
    padding: 4px 10px;
  }
  #board li {
    gap: 5px;
  }
  #feed li:nth-child(n + 3) {
    display: none;
  }
  #toast {
    top: calc(max(10px, env(safe-area-inset-top)) + 60px);
  }
  .weapons {
    right: calc(max(22px, env(safe-area-inset-right)) + 108px);
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 420px);
    flex-wrap: wrap-reverse;
  }
  /* One row: the picture and the count, no name. */
  .weapons {
    gap: 4px;
  }
  .weapons button {
    min-width: 40px;
    padding: 4px 2px 2px;
  }
  .weapons button span {
    display: none;
  }
}
