:root {
  color-scheme: dark;
  --ink: #f7f4ea;
  --muted: #aab7c9;
  --panel: rgba(17, 28, 44, 0.92);
  --panel-soft: rgba(26, 41, 62, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --gold: #ffc64d;
  --gold-deep: #e58a18;
  --cyan: #69e6ef;
  --green: #65df9c;
  --danger: #ff8d85;
  --shadow: 0 24px 70px rgba(1, 7, 16, 0.46);
  --radius: 24px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #0b1321;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 8%, rgba(45, 112, 130, 0.23), transparent 31rem),
    radial-gradient(circle at 88% 16%, rgba(186, 107, 34, 0.18), transparent 34rem),
    linear-gradient(145deg, #0b1321, #101c2e 54%, #0a111d);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

button {
  min-height: 44px;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  color: #102034;
  background: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 226, 150, 0.32);
  border-radius: 16px;
  color: #271607;
  font-size: 1.65rem;
  font-weight: 900;
  background: linear-gradient(145deg, #ffe18c, #f1a72b);
  box-shadow: 0 10px 24px rgba(225, 137, 27, 0.2);
  transform: rotate(-6deg);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  letter-spacing: 0.02em;
}

.brand div > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0.64rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #dce5f2;
  background: rgba(21, 34, 52, 0.76);
  backdrop-filter: blur(12px);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  border-color: rgba(105, 230, 239, 0.34);
  background: rgba(34, 53, 78, 0.9);
  transform: translateY(-1px);
}

.icon-button[aria-pressed="false"] {
  color: #8995a8;
}

.scoreboard {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr 1.18fr 0.9fr;
  gap: 10px;
}

.stat-card {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(29, 45, 66, 0.94), rgba(17, 29, 46, 0.94));
  box-shadow: 0 12px 28px rgba(2, 8, 18, 0.14);
}

.stat-card > span {
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-card strong {
  color: #fff;
  font-size: clamp(1.05rem, 2.6vw, 1.42rem);
  white-space: nowrap;
}

.stat-card strong b {
  color: inherit;
  font-size: 1.55em;
}

.stat-card strong small {
  margin-left: 3px;
  color: #9eabc0;
  font-size: 0.68em;
  font-weight: 600;
}

.stat-level strong,
.stat-score strong {
  color: var(--gold);
}

.stat-time strong {
  color: var(--cyan);
}

.stat-time.is-urgent strong {
  color: var(--danger);
  animation: urgent-pulse 800ms ease-in-out infinite alternate;
}

.goal-strip {
  margin: 10px 0 14px;
  padding: 10px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(14, 25, 40, 0.72);
}

.goal-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #d7e0ec;
  font-size: 0.84rem;
}

.goal-meta {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mode-badge {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(105, 230, 239, 0.16);
  border-radius: 999px;
  color: #a9dce5;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
  background: rgba(105, 230, 239, 0.07);
}

#starTotal {
  color: #ffe080;
  font-weight: 800;
  white-space: nowrap;
}

.goal-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.goal-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e89b27, #ffd75f 58%, #fff0a3);
  box-shadow: 0 0 15px rgba(255, 199, 77, 0.46);
  transition: width 260ms ease;
}

.game-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  background: #0d1827;
  box-shadow: var(--shadow);
}

.canvas-stage {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #4b2d1c;
  isolation: isolate;
}

.canvas-stage::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 76px rgba(1, 7, 15, 0.42);
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.toast {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 4;
  max-width: calc(100% - 28px);
  padding: 0.68rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  background: rgba(11, 22, 37, 0.84);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(10px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-good {
  border-color: rgba(101, 223, 156, 0.5);
  color: #c7ffe0;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  background: rgba(5, 12, 23, 0.68);
  backdrop-filter: blur(8px) saturate(0.85);
}

.screen-panel {
  width: min(610px, 100%);
  margin: auto;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  text-align: center;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 196, 74, 0.18), transparent 48%),
    linear-gradient(155deg, rgba(30, 46, 67, 0.97), rgba(13, 24, 40, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.screen-panel h1,
.screen-panel h2 {
  margin: 8px 0 8px;
  line-height: 1.12;
}

.screen-panel h1 {
  color: #fff3c6;
  font-size: clamp(2rem, 6vw, 3.35rem);
  letter-spacing: 0.03em;
  text-shadow: 0 4px 22px rgba(245, 162, 38, 0.32);
}

.screen-panel h2 {
  font-size: clamp(1.55rem, 4vw, 2.25rem);
}

.screen-panel p {
  color: #bcc8d8;
  line-height: 1.65;
}

.screen-panel .lead {
  margin: 0 auto 20px;
  max-width: 470px;
  font-size: 1rem;
}

.how-to-play {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 18px 0 22px;
}

.how-to-play div {
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.how-to-play div > span,
.how-to-play b,
.how-to-play small {
  display: block;
}

.how-to-play div > span {
  margin-bottom: 6px;
  font-size: 1.5rem;
}

.how-to-play b {
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.how-to-play small {
  color: #9eacbf;
  font-size: 0.72rem;
  line-height: 1.35;
}

.screen-actions {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-width: 150px;
  padding: 0.82rem 1.15rem;
  border-radius: 14px;
  font-size: 0.94rem;
  font-weight: 800;
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button {
  color: #2b1908;
  background: linear-gradient(145deg, #ffe38a, #f5aa2e);
  box-shadow: 0 10px 24px rgba(230, 142, 25, 0.24);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.13);
  color: #e6edf6;
  background: #263a54;
}

.primary-button:hover,
.secondary-button:hover,
.drop-button:hover,
.finish-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.text-button {
  min-height: 36px;
  margin-top: 10px;
  padding: 0.35rem 0.5rem;
  color: #9fdbe3;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  background: transparent;
}

.compact-panel {
  width: min(470px, 100%);
}

.big-icon {
  display: block;
  color: var(--gold);
  font-size: clamp(2.4rem, 7vw, 4.5rem);
}

.result-badge {
  display: grid;
  width: 74px;
  height: 74px;
  margin: -2px auto 6px;
  place-items: center;
  border: 1px solid rgba(255, 224, 128, 0.28);
  border-radius: 50%;
  font-size: 2.15rem;
  background: rgba(255, 197, 67, 0.1);
}

.result-stars {
  margin: 8px 0;
  color: var(--gold);
  font-size: clamp(2rem, 7vw, 3.4rem);
  letter-spacing: 0.16em;
  text-shadow: 0 0 22px rgba(255, 198, 77, 0.4);
}

.record-note {
  min-height: 1.5em;
  margin-top: -8px;
  color: var(--cyan) !important;
  font-size: 0.84rem;
}

.level-screen {
  place-items: stretch center;
}

.level-panel {
  width: min(810px, 100%);
  padding: clamp(16px, 3vw, 26px);
  text-align: left;
}

.level-heading,
.chapter-caption,
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.level-heading h2 {
  margin: 4px 0 0;
}

.close-button {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #dbe6f2;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.06);
}

.chapter-tabs {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin: 18px 0 13px;
}

.chapter-tab {
  min-height: 38px;
  padding: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #a9b7c8;
  font-size: 0.76rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.045);
}

.chapter-tab[aria-selected="true"] {
  border-color: rgba(255, 207, 92, 0.42);
  color: #2a1907;
  background: var(--gold);
}

.chapter-tab.is-locked {
  opacity: 0.42;
}

.chapter-caption {
  margin-bottom: 10px;
}

.chapter-caption strong {
  color: #fff2c5;
  font-size: 1.05rem;
}

.chapter-caption span,
.map-footer > span {
  color: #9cabbf;
  font-size: 0.78rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 7px;
}

.level-tile {
  position: relative;
  display: grid;
  min-height: 54px;
  padding: 5px 2px 4px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #eaf0f7;
  font-weight: 850;
  background: rgba(255, 255, 255, 0.055);
}

.level-tile small {
  display: block;
  min-height: 1em;
  color: var(--gold);
  font-size: 0.57rem;
  letter-spacing: -0.08em;
}

.level-tile:hover:not(:disabled) {
  border-color: rgba(105, 230, 239, 0.45);
  background: rgba(105, 230, 239, 0.1);
}

.level-tile.is-current {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 77, 0.4);
}

.level-tile.is-admin-unlocked {
  border-color: rgba(105, 230, 239, 0.34);
  color: #d9fcff;
  background: linear-gradient(145deg, rgba(105, 230, 239, 0.12), rgba(200, 153, 255, 0.08));
}

.level-tile.is-admin-unlocked small {
  color: var(--cyan);
  letter-spacing: 0;
}

.level-tile:disabled {
  color: #68788d;
  background: rgba(3, 10, 19, 0.32);
}

.level-tile:disabled::after {
  content: "🔒";
  font-size: 0.7rem;
}

.map-footer {
  margin-top: 12px;
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
  padding: 10px 11px;
  border: 1px solid rgba(105, 230, 239, 0.16);
  border-radius: 15px;
  background: rgba(12, 26, 43, 0.72);
}

.admin-bar.is-active {
  border-color: rgba(101, 223, 156, 0.42);
  background: linear-gradient(135deg, rgba(45, 130, 86, 0.2), rgba(31, 69, 100, 0.24));
  box-shadow: inset 0 0 24px rgba(101, 223, 156, 0.06);
}

.admin-shield {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: rgba(105, 230, 239, 0.1);
}

.admin-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.admin-copy strong,
.admin-copy small {
  display: block;
}

.admin-copy strong {
  color: #ecf8ff;
  font-size: 0.88rem;
}

.admin-copy small {
  margin-top: 2px;
  color: #93a7bd;
  font-size: 0.72rem;
  line-height: 1.4;
}

.admin-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(105, 230, 239, 0.28);
  border-radius: 11px;
  color: #c9faff;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(52, 118, 136, 0.22);
}

.admin-bar.is-active .admin-button {
  border-color: rgba(255, 141, 133, 0.25);
  color: #ffd2ce;
  background: rgba(145, 59, 55, 0.18);
}

.admin-panel {
  width: min(480px, 100%);
  text-align: left;
}

.admin-panel > .eyebrow,
.admin-panel > h2,
.admin-panel > p,
.admin-lock {
  text-align: center;
}

.admin-lock {
  display: block;
  margin-bottom: 3px;
  font-size: clamp(2rem, 7vw, 3.35rem);
}

.password-field {
  display: block;
  margin-top: 13px;
}

.password-field > span {
  display: block;
  margin-bottom: 6px;
  color: #ced9e6;
  font-size: 0.83rem;
  font-weight: 750;
}

.password-field input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  outline: none;
  color: #fff;
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.08em;
  background: rgba(5, 14, 25, 0.65);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(105, 230, 239, 0.12);
}

.form-error {
  min-height: 1.45em;
  margin: 8px 0 10px;
  color: #ffaaa3 !important;
  font-size: 0.78rem;
  text-align: left !important;
}

.admin-note {
  margin: 13px 0 -4px;
  color: #8294aa !important;
  font-size: 0.72rem;
  text-align: center !important;
}

.settings-panel {
  width: min(700px, 100%);
  text-align: left;
}

.settings-heading,
.setting-label-row,
.weight-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-heading h2 {
  margin: 4px 0 0;
}

.difficulty-fieldset {
  min-width: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.difficulty-fieldset legend,
.setting-label-row label {
  color: #e8eff7;
  font-size: 0.9rem;
  font-weight: 800;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 9px;
}

.difficulty-option {
  position: relative;
  min-width: 0;
  padding: 13px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  text-align: center;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.difficulty-option:hover {
  border-color: rgba(105, 230, 239, 0.34);
  transform: translateY(-1px);
}

.difficulty-option:has(input:checked) {
  border-color: rgba(255, 205, 82, 0.55);
  background: linear-gradient(145deg, rgba(255, 198, 77, 0.16), rgba(105, 230, 239, 0.07));
  box-shadow: inset 0 0 0 1px rgba(255, 198, 77, 0.18);
}

.difficulty-option:has(input:focus-visible) {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.difficulty-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.difficulty-option > span,
.difficulty-option strong,
.difficulty-option small {
  display: block;
}

.difficulty-option > span {
  margin-bottom: 5px;
  font-size: 1.45rem;
}

.difficulty-option strong {
  color: #fff;
  font-size: 0.9rem;
}

.difficulty-option small {
  margin-top: 4px;
  color: #96a6ba;
  font-size: 0.72rem;
  line-height: 1.35;
}

.speed-setting {
  margin-top: 16px;
  padding: 14px 15px 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 15px;
  background: rgba(4, 13, 24, 0.28);
}

.setting-label-row output {
  min-width: 58px;
  padding: 0.25rem 0.48rem;
  border-radius: 9px;
  color: #172211;
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
  background: var(--gold);
}

#hookSpeedRange {
  width: 100%;
  height: 28px;
  margin: 10px 0 2px;
  accent-color: var(--gold);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: #7f91a7;
  font-size: 0.69rem;
}

.weight-preview {
  margin-top: 12px;
  padding: 12px 15px;
  border: 1px solid rgba(105, 230, 239, 0.1);
  border-radius: 15px;
  background: rgba(10, 26, 42, 0.5);
}

.weight-preview-heading {
  margin-bottom: 9px;
}

.weight-preview-heading strong {
  color: #dbe8f4;
  font-size: 0.82rem;
}

.weight-preview-heading small {
  color: #8498ae;
  font-size: 0.7rem;
}

.weight-row {
  display: grid;
  grid-template-columns: 92px minmax(70px, 1fr) 76px;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  color: #b9c6d5;
  font-size: 0.74rem;
}

.weight-row i {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.weight-row em {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #56cbd6, #ffcf58);
  transition: width 140ms ease;
}

.weight-row b {
  color: #d8e4ef;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.settings-note {
  margin: 10px 0 12px;
  color: #8ea0b4 !important;
  font-size: 0.75rem;
  text-align: center;
}

.danger-text {
  flex: 0 0 auto;
  color: #d89b9b;
}

.play-controls {
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #122137, #101c2e);
}

.tip-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #aebacc;
  font-size: 0.86rem;
}

.tip-key {
  display: inline-grid;
  min-width: 54px;
  min-height: 30px;
  padding: 0 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-bottom-width: 3px;
  border-radius: 8px;
  color: #dde7f2;
  font-size: 0.72rem;
  font-weight: 800;
  background: #283b54;
}

.control-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.drop-button,
.finish-button {
  min-height: 56px;
  padding: 0.72rem 1.2rem;
  border-radius: 17px;
  font-weight: 900;
  transition: transform 150ms ease, filter 150ms ease;
}

.drop-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 180px;
  color: #261707;
  background: linear-gradient(145deg, #ffe592, #f5ad31);
  box-shadow: 0 12px 26px rgba(218, 132, 23, 0.25);
}

.drop-button span {
  font-size: 1.35rem;
}

.drop-button:disabled {
  color: #8490a0;
  background: #29384b;
  box-shadow: none;
}

.finish-button {
  border: 1px solid rgba(101, 223, 156, 0.38);
  color: #caffdf;
  background: rgba(47, 139, 91, 0.28);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  padding: 16px 10px 0;
  color: #8f9db1;
  font-size: 0.78rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.legend-dot.gold { color: var(--gold); background: currentColor; }
.legend-dot.diamond { color: var(--cyan); background: currentColor; }
.legend-dot.clock { color: var(--green); background: currentColor; }
.legend-dot.bag { color: #d39a68; background: currentColor; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes urgent-pulse {
  to { transform: scale(1.05); }
}

@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .button-label {
    display: none;
  }

  .icon-button {
    width: 44px;
    padding: 0;
  }

  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card {
    min-height: 64px;
    padding: 10px 13px;
  }

  .chapter-tabs {
    grid-template-columns: repeat(5, 1fr);
  }

  .level-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .settings-panel {
    padding: 17px;
  }

  .admin-bar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .admin-copy {
    width: calc(100% - 52px);
  }

  .admin-button {
    width: 100%;
  }

  .play-controls {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .tip-line {
    justify-content: center;
  }

  .control-buttons {
    width: 100%;
  }

  .drop-button,
  .finish-button {
    flex: 1 1 0;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: calc(100% - 12px);
    padding-bottom: 20px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    font-size: 1.4rem;
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand div > span {
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 5px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .scoreboard {
    gap: 6px;
  }

  .stat-card {
    min-height: 56px;
    padding: 8px 10px;
    border-radius: 13px;
  }

  .stat-card > span {
    font-size: 0.7rem;
  }

  .stat-card strong {
    font-size: 0.94rem;
  }

  .goal-strip {
    margin-top: 7px;
  }

  .goal-meta {
    gap: 5px;
  }

  .mode-badge {
    font-size: 0.64rem;
  }

  .game-card {
    border-radius: 17px;
  }

  .screen {
    align-items: start;
    padding: 8px;
  }

  .screen-panel {
    border-radius: 18px;
  }

  .start-panel {
    padding: 15px;
  }

  .screen-panel h1 {
    margin-top: 4px;
    font-size: 1.65rem;
  }

  .screen-panel .lead {
    margin-bottom: 10px;
    font-size: 0.82rem;
  }

  .how-to-play {
    gap: 5px;
    margin: 8px 0 12px;
  }

  .how-to-play div {
    padding: 7px 4px;
    border-radius: 11px;
  }

  .how-to-play div > span {
    margin-bottom: 2px;
    font-size: 1.15rem;
  }

  .how-to-play small {
    display: none;
  }

  .screen-actions {
    gap: 7px;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }

  .difficulty-option {
    display: grid;
    grid-template-columns: 34px 70px 1fr;
    align-items: center;
    padding: 8px 10px;
    text-align: left;
  }

  .difficulty-option > span {
    margin: 0;
    text-align: center;
  }

  .difficulty-option small {
    margin: 0;
  }

  .weight-row {
    grid-template-columns: 82px minmax(50px, 1fr) 68px;
    gap: 6px;
  }

  .primary-button,
  .secondary-button {
    min-width: 0;
    padding: 0.65rem 0.8rem;
    font-size: 0.82rem;
  }

  .play-controls {
    padding: 10px;
  }

  .tip-line {
    font-size: 0.74rem;
  }

  .tip-key {
    display: none;
  }

  .drop-button,
  .finish-button {
    min-width: 0;
    min-height: 50px;
    padding: 0.55rem 0.65rem;
    font-size: 0.82rem;
  }

  .legend {
    justify-content: flex-start;
    gap: 8px 14px;
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
