:root {
  --bg: #151711;
  --panel: rgba(19, 22, 17, 0.72);
  --line: rgba(239, 231, 203, 0.14);
  --text: #f6eed5;
  --muted: #a69b7e;
  --accent: #d7b56d;
  --danger: #e2695c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  -webkit-touch-callout: none;
  user-select: none;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(215, 181, 109, 0.2), transparent 30rem),
    radial-gradient(circle at 78% 18%, rgba(88, 128, 115, 0.17), transparent 26rem),
    linear-gradient(145deg, #1a1d15, #0c0d0b 70%);
  color: var(--text);
  font-family:
    "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.shell {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 20px;
}

.game-stage {
  position: relative;
  width: min(1280px, 100%);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0c0d0b;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.46);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.hud {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}

.hud > div {
  min-width: 116px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(20, 24, 18, 0.78), rgba(8, 10, 8, 0.68));
  padding: 10px 12px;
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 24px rgba(0,0,0,0.2);
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1;
}

.message {
  position: absolute;
  left: 50%;
  top: 102px;
  max-width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  border: 1px solid rgba(215, 181, 109, 0.28);
  border-radius: 14px;
  background: rgba(11, 12, 10, 0.76);
  color: #f4df9f;
  padding: 10px 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(12px);
  pointer-events: none;
  z-index: 3;
}

.message.show {
  opacity: 1;
}

.top-actions {
  position: absolute;
  right: 18px;
  top: 112px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.bgm-toggle,
.codex-toggle,
.cloak-toggle,
.exam-toggle {
  border: 1px solid rgba(215, 181, 109, 0.3);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(246, 238, 213, 0.96), rgba(215, 181, 109, 0.88));
  color: #11140f;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
  pointer-events: auto;
}

.cloak-toggle {
  min-width: 112px;
  background: rgba(10, 11, 9, 0.72);
  color: #f6eed5;
}

.exam-toggle {
  min-width: 104px;
  background: rgba(10, 11, 9, 0.72);
  color: #f6eed5;
}

.cloak-toggle.is-ready,
.cloak-toggle.is-active,
.exam-toggle.is-ready,
.exam-toggle.is-active {
  border-color: rgba(154, 219, 208, 0.55);
  background: linear-gradient(145deg, rgba(154, 219, 208, 0.96), rgba(83, 151, 139, 0.9));
  color: #0f211d;
}

.exam-toggle.is-ready,
.exam-toggle.is-active {
  border-color: rgba(226, 105, 92, 0.45);
  background: linear-gradient(145deg, rgba(246, 238, 213, 0.98), rgba(226, 105, 92, 0.78));
}

.cloak-toggle:disabled,
.exam-toggle:disabled {
  cursor: default;
  opacity: 0.72;
}

.bgm-toggle.is-muted {
  border-color: rgba(246, 238, 213, 0.2);
  background: rgba(10, 11, 9, 0.72);
  color: #f6eed5;
}

.help-strip {
  display: none;
}

.start {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 30px;
  background:
    radial-gradient(circle at 50% 44%, rgba(215, 181, 109, 0.16), transparent 22rem),
    rgba(7, 8, 7, 0.72);
  text-align: center;
  backdrop-filter: blur(4px);
  z-index: 5;
}

.start[hidden] {
  display: none;
}

.account-gate {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 44%, rgba(215, 181, 109, 0.18), transparent 22rem),
    rgba(5, 7, 6, 0.82);
  backdrop-filter: blur(6px);
}

.account-gate[hidden] {
  display: none;
}

.account-card {
  width: min(620px, 100%);
  border: 1px solid rgba(215, 181, 109, 0.24);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(24, 30, 24, 0.92), rgba(9, 11, 9, 0.92));
  padding: 34px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
}

.account-card h1 {
  font-size: clamp(42px, 8vw, 82px);
}

.account-card p:not(.kicker) {
  max-width: 480px;
  margin: 20px auto 24px;
  color: #d8cfb6;
  line-height: 1.8;
}

.account-form {
  display: flex;
  gap: 10px;
  margin: 0 auto;
  max-width: 470px;
}

.account-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid rgba(246, 238, 213, 0.18);
  border-radius: 999px;
  background: rgba(246, 238, 213, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  padding: 14px 18px;
  outline: none;
}

.account-form input:focus {
  border-color: rgba(215, 181, 109, 0.7);
  box-shadow: 0 0 0 4px rgba(215, 181, 109, 0.12);
}

.account-form button {
  padding: 14px 24px;
}

.account-error {
  min-height: 24px;
  margin: 12px 0 0;
  color: #e2695c;
  font-weight: 800;
}

.kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.36em;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 9vw, 104px);
  line-height: 0.92;
}

.start p:not(.kicker) {
  max-width: 520px;
  margin: 22px auto 28px;
  color: #d8cfb6;
  font-size: 16px;
  line-height: 1.8;
}

.level-select {
  display: flex;
  max-width: 720px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 18px;
}

.level-button {
  border: 1px solid rgba(246, 238, 213, 0.22);
  border-radius: 999px;
  background: rgba(246, 238, 213, 0.08);
  color: #f6eed5;
  padding: 9px 14px;
}

.level-button.active {
  border-color: rgba(215, 181, 109, 0.72);
  background: rgba(215, 181, 109, 0.92);
  color: #151711;
}

.level-button.locked {
  opacity: 0.42;
  cursor: not-allowed;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: #10110d;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

#startBtn {
  padding: 14px 30px;
}

.mobile-controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 4;
}

.joystick {
  position: relative;
  width: 124px;
  height: 124px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(246, 238, 213, 0.13), rgba(115, 142, 128, 0.14));
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  touch-action: none;
}

.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 249, 226, 0.96), rgba(222, 210, 176, 0.9));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.phone-button,
.sprint-button {
  position: relative;
  width: 104px;
  height: 104px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(246, 238, 213, 0.98), rgba(215, 181, 109, 0.9)),
    rgba(215, 181, 109, 0.9);
  color: #151711;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-origin: 50% 58%;
  transition:
    box-shadow 0.16s ease,
    filter 0.16s ease,
    transform 0.16s ease;
}

.sprint-button {
  background:
    linear-gradient(145deg, rgba(111, 199, 178, 0.98), rgba(84, 144, 132, 0.94)),
    rgba(111, 199, 178, 0.9);
  font-size: 18px;
  letter-spacing: 0.12em;
}

.phone-button::after,
.sprint-button::after,
.cloak-toggle::after,
.exam-toggle::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 20px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.42), transparent 58%);
  opacity: 0;
  transform: scale(0.55);
  pointer-events: none;
}

.phone-button:active,
.sprint-button:active,
.cloak-toggle:active,
.exam-toggle:active {
  filter: brightness(1.08) saturate(1.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

.phone-button.is-jelly,
.sprint-button.is-jelly,
.cloak-toggle.is-jelly,
.exam-toggle.is-jelly {
  animation: jelly-press 260ms cubic-bezier(0.18, 0.9, 0.26, 1.08) both;
}

.phone-button.is-jelly::after,
.sprint-button.is-jelly::after,
.cloak-toggle.is-jelly::after,
.exam-toggle.is-jelly::after {
  animation: button-pop 300ms ease-out both;
}

@keyframes jelly-press {
  0% {
    transform: scale(1);
  }
  22% {
    transform: scale(0.94, 1.04);
  }
  62% {
    transform: scale(1.035, 0.975);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes button-pop {
  0% {
    opacity: 0.45;
    transform: scale(0.5);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

.codex-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 6, 5, 0.64);
  backdrop-filter: blur(8px);
}

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

.codex-card {
  position: relative;
  width: min(460px, 100%);
  border: 1px solid rgba(215, 181, 109, 0.25);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(24, 31, 25, 0.96), rgba(11, 13, 10, 0.96));
  padding: 28px;
  color: #f6eed5;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.codex-card h2 {
  margin: 6px 0 14px;
  font-size: 32px;
}

.codex-card p:not(.kicker) {
  margin: 12px 0 0;
  color: #d8cfb6;
  line-height: 1.8;
}

.codex-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
}

.codex-item-icon {
  display: grid;
  width: 84px;
  height: 84px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(145deg, #a8e4dc, #55998d);
  color: #10231f;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 18px 40px rgba(93, 182, 166, 0.25);
}

.codex-item-icon.exam {
  background: linear-gradient(145deg, #fff4d4, #e2695c);
  color: #2a130f;
}

.codex-divider {
  height: 1px;
  margin: 22px 0;
  background: rgba(246, 238, 213, 0.14);
}

.phone-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 66px;
  transform: translate(-50%, -50%);
  border: 4px solid #151711;
  border-radius: 10px;
  background: linear-gradient(180deg, #17231f, #254940);
  box-shadow:
    inset 0 8px 0 rgba(111, 199, 178, 0.42),
    0 8px 0 rgba(0, 0, 0, 0.12);
}

.phone-icon::before,
.phone-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: #f6eed5;
}

.phone-icon::before {
  top: 6px;
  width: 16px;
  height: 3px;
  border-radius: 999px;
}

.phone-icon::after {
  bottom: 5px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

@media (max-width: 760px), (pointer: coarse) {
  .shell {
    padding: 0;
  }

  .game-stage {
    width: 100%;
    height: 100dvh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
  }

  .hud {
    left: 10px;
    right: 10px;
    top: 10px;
    gap: 6px;
  }

  .hud > div {
    min-width: 0;
    flex: 1;
    padding: 7px 8px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 0.12em;
  }

  .hud strong {
    font-size: 16px;
  }

  .message {
    top: 72px;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
  }

  .top-actions {
    top: 154px;
    right: 12px;
    max-width: calc(100% - 24px);
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .bgm-toggle,
  .codex-toggle,
  .cloak-toggle,
  .exam-toggle {
    padding: 7px 11px;
    font-size: 11px;
  }

  .level-select {
    flex-wrap: wrap;
    gap: 8px;
  }

  .level-button {
    padding: 9px 12px;
    font-size: 13px;
  }

  .mobile-controls {
    display: flex;
  }

  .account-card {
    padding: 26px 18px;
  }

  .account-form {
    flex-direction: column;
  }

  .account-form button,
  .account-form input {
    width: 100%;
  }

  .action-buttons {
    gap: 8px;
  }

  .joystick {
    width: 116px;
    height: 116px;
  }

  .phone-button {
    width: 88px;
    height: 88px;
    font-size: 16px;
  }

  .sprint-button {
    width: 88px;
    height: 88px;
  }

  .phone-icon {
    width: 34px;
    height: 54px;
  }
}
