:root {
  color-scheme: dark;
  --ink: #f7f1dc;
  --muted: #b9b3a7;
  --panel: rgba(20, 28, 31, 0.86);
  --panel-solid: #172126;
  --line: rgba(255, 255, 255, 0.13);
  --accent: #f3c14b;
  --accent-2: #48c7a6;
  --danger: #ef5a4f;
  --street: #26343b;
  --street-2: #1d2a30;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 54px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 54px),
    linear-gradient(135deg, #10171b 0%, #1f2f35 48%, #11181d 100%);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 24px);
  display: grid;
  grid-template-columns: minmax(320px, 680px) 260px;
  justify-content: center;
  gap: 16px;
  align-items: stretch;
}

.game-column,
.side-panel {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(25px, 5.4vw, 46px);
  line-height: 0.96;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: clamp(13px, 3.2vw, 16px);
}

.icon-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 25px;
  display: grid;
  place-items: center;
}

.icon-button:hover,
.mobile-controls button:hover,
#startBtn:hover {
  filter: brightness(1.12);
}

.hud {
  display: grid;
  grid-template-columns: 0.75fr 1.5fr 0.75fr 0.75fr;
  gap: 8px;
  margin-bottom: 10px;
}

.meter {
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

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

.meter strong {
  font-size: 23px;
  line-height: 1;
}

.heat-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  outline: 1px solid rgba(255, 255, 255, 0.1);
}

#heatFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--danger));
  transition: width 120ms linear;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: var(--street-2);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

canvas {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: calc(100vh - 218px);
  display: block;
  background: var(--street);
  touch-action: none;
}

.message-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100% - 28px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(14, 20, 24, 0.91);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  display: grid;
  gap: 12px;
  text-align: center;
}

.message-panel[hidden] {
  display: none;
}

.message-panel strong {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
}

.message-panel span {
  color: var(--muted);
  line-height: 1.6;
}

#startBtn {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f0be42, #e97954);
  color: #151511;
  font-weight: 800;
}

.side-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.poster,
.brief,
.legend {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.poster {
  padding: 18px;
  text-align: center;
  background:
    linear-gradient(rgba(255, 244, 199, 0.88), rgba(238, 207, 139, 0.88)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(0, 0, 0, 0.08) 12px 14px);
  color: #2a1c14;
}

.poster-label {
  border: 4px solid currentColor;
  padding: 5px 8px;
  font-size: 34px;
  font-weight: 950;
  line-height: 1;
}

.poster-face {
  width: 118px;
  height: 118px;
  margin: 18px auto 12px;
  border: 5px solid #2a1c14;
  border-radius: 50%;
  background:
    linear-gradient(transparent 44%, #2a1c14 45% 51%, transparent 52%),
    radial-gradient(circle at 36% 44%, #2a1c14 0 5px, transparent 6px),
    radial-gradient(circle at 64% 44%, #2a1c14 0 5px, transparent 6px),
    radial-gradient(circle at 50% 62%, #2a1c14 0 10px, transparent 11px),
    #f2c999;
  position: relative;
}

.poster-face::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 18px;
  height: 30px;
  border-radius: 40px 40px 8px 8px;
  background: #221812;
}

.poster-face span {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 24px;
  height: 10px;
  border-radius: 999px;
  background: #221812;
}

.poster strong {
  display: block;
  font-size: 22px;
}

.poster p {
  margin-top: 6px;
  color: rgba(42, 28, 20, 0.78);
}

.brief,
.legend {
  padding: 16px;
}

.brief h2,
.legend h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.brief ul {
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
  line-height: 1.72;
}

.legend {
  display: grid;
  gap: 10px;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.dot.player {
  background: #f3c14b;
}

.dot.guard {
  background: #ef5a4f;
}

.dot.item {
  background: #48c7a6;
}

.dot.hideout {
  border-radius: 3px;
  background: #8c6f46;
}

.touch-controls {
  min-height: 118px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 164px 1fr;
  gap: 14px;
  align-items: center;
}

.dpad {
  width: 164px;
  height: 116px;
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(3, 35px);
  gap: 6px;
}

.dpad button,
.hide-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
}

.dpad [data-move="up"] {
  grid-column: 2;
  grid-row: 1;
}

.dpad [data-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.dpad [data-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

.dpad [data-move="down"] {
  grid-column: 2;
  grid-row: 3;
}

.hide-button {
  justify-self: end;
  width: min(32vw, 118px);
  height: min(32vw, 118px);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffe193, #e97954 72%);
  color: #20160f;
  font-size: 38px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
}

.hide-button:active,
.dpad button:active,
.icon-button:active,
#startBtn:active {
  transform: translateY(1px) scale(0.99);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(720px, 100%);
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .poster-label {
    font-size: 27px;
  }

  .poster-face {
    width: 88px;
    height: 88px;
  }
}

@media (max-width: 680px) {
  body {
    overflow: hidden;
  }

  .shell {
    min-height: 100svh;
    padding: 10px;
    display: block;
  }

  .hud {
    grid-template-columns: 0.78fr 1.35fr 0.75fr 0.75fr;
    gap: 6px;
  }

  .meter {
    min-height: 46px;
    padding: 7px 8px;
  }

  .meter span {
    font-size: 11px;
  }

  .meter strong {
    font-size: 20px;
  }

  .topbar {
    align-items: start;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  canvas {
    max-height: calc(100svh - 222px);
  }

  .message-panel {
    padding: 16px;
  }

  .side-panel {
    display: none;
  }

  .touch-controls {
    grid-template-columns: 164px 1fr;
    margin-top: 8px;
  }

  .dpad {
    width: 164px;
    height: 116px;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 35px);
    gap: 6px;
  }
}

@media (max-width: 390px) {
  .topbar p {
    display: none;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .heat-track {
    height: 12px;
  }

  canvas {
    max-height: calc(100svh - 202px);
  }

  .touch-controls {
    grid-template-columns: 146px 1fr;
  }

  .dpad {
    width: 146px;
    height: 106px;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 32px);
    gap: 5px;
  }

  .hide-button {
    width: min(34vw, 110px);
    height: min(34vw, 110px);
  }
}
