* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b121b;
  --cabinet-back: #141e2b;
  --glass: #263f54;
  --prize-bed: #1e2d38;
  --rail: #c6d3e0;
  --cable: #e5f4ff;
  --claw-hub: #f9ba38;
  --claw-arms: #ffe56b;
  --drop: #ffc942;
  --gold: #ffdb51;
  --ink: #eaf4ff;
  --muted: #9db4cc;
  --quiet: #6f879f;
  --root-panel: rgba(20, 30, 43, 0.98);
  --root-edge: rgba(249, 186, 56, 0.32);
  --board-edge: rgba(198, 211, 224, 0.22);
  --info-panel: rgba(30, 45, 56, 0.92);
  --footer-panel: rgba(11, 18, 27, 0.94);
  --secondary-btn: #1b2a39;
  --disabled: #10171f;
  --disabled-label: #4a5a6c;
  --shadow: rgba(0, 0, 0, 0.5);
  --deep-shadow: rgba(0, 0, 0, 0.66);
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(249, 186, 56, 0.12) 0 22%, transparent 60%),
    linear-gradient(180deg, #16222f 0%, #0b121b 56%, #060a10 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Microsoft YaHei", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.play-shell {
  width: min(1080px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  text-decoration: none;
}

.brand::before {
  width: 18px;
  height: 18px;
  border: 2px solid var(--root-edge);
  border-radius: 5px;
  background:
    radial-gradient(circle at 50% 32%, var(--claw-arms) 0 22%, transparent 24%),
    linear-gradient(180deg, var(--claw-hub) 0 44%, transparent 45%),
    var(--glass);
  box-shadow: 0 0 18px rgba(249, 186, 56, 0.32);
  content: "";
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pills span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--board-edge);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--muted);
  background: var(--info-panel);
  box-shadow: inset 0 1px 0 rgba(229, 244, 255, 0.05);
  font-size: 13px;
  font-weight: 900;
}

#bookLabel {
  color: var(--gold);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: stretch;
  gap: clamp(16px, 4vw, 38px);
}

.stage-panel,
.hud {
  border: 1px solid var(--root-edge);
  border-radius: 8px;
  background: var(--root-panel);
  box-shadow: 0 26px 80px var(--deep-shadow);
}

.stage-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(78svh, 760px);
  overflow: hidden;
  padding: clamp(12px, 3vw, 24px);
}

#gameCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: auto;
  height: min(74svh, 720px);
  max-width: 100%;
  aspect-ratio: 76 / 100;
  border: 1px solid var(--board-edge);
  border-radius: 10px;
  background: var(--cabinet-back);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(249, 186, 56, 0.12);
  touch-action: manipulation;
}

.message {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 18px;
  max-width: calc(100% - 28px);
  border: 1px solid rgba(249, 186, 56, 0.5);
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--ink);
  background: rgba(8, 13, 19, 0.92);
  box-shadow: 0 16px 40px var(--shadow);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.hud {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(16px, 3vw, 26px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--drop);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hud h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 0.96;
}

.hud p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aim-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 10px;
}

button {
  min-height: 56px;
  border: 1px solid var(--board-edge);
  border-radius: 10px;
  color: var(--ink);
  background: var(--secondary-btn);
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.aim-btn,
.drop-btn,
.util-btn {
  position: relative;
  overflow: hidden;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.34), 0 12px 24px rgba(0, 0, 0, 0.24);
}

.aim-btn::before,
.drop-btn::before {
  position: absolute;
  inset: 10% 10% 58%;
  border-radius: 7px;
  background: rgba(255, 246, 216, 0.1);
  content: "";
  pointer-events: none;
}

.aim-btn {
  color: var(--gold);
  background: #1f2f3f;
  font-size: 26px;
}

.drop-btn {
  color: #11100c;
  background: var(--drop);
  border-color: var(--root-edge);
  font-size: 22px;
  letter-spacing: 0.04em;
}

.drop-btn::before {
  background: rgba(255, 244, 204, 0.24);
}

.util-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.util-btn {
  min-height: 48px;
  font-size: 14px;
  background: var(--footer-panel);
}

.util-btn.daily {
  color: var(--gold);
  border-color: rgba(255, 219, 81, 0.4);
}

.util-btn.daily.active {
  color: #11100c;
  background: var(--gold);
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: rgba(234, 244, 255, 0.8);
  transform: translateY(-1px);
}

.drop-btn:hover:not(:disabled),
.drop-btn:focus-visible {
  color: #11100c;
}

.util-btn.daily.active:hover {
  color: #11100c;
}

button:active:not(:disabled) {
  transform: translateY(2px);
}

button:disabled {
  border-color: rgba(40, 54, 68, 0.7);
  color: var(--disabled-label);
  background: var(--disabled);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.26);
  cursor: not-allowed;
}

.control-note {
  color: var(--quiet) !important;
  font-size: 13px !important;
}

@media (max-width: 900px) {
  .play-shell {
    width: calc(100% - 24px);
    max-width: 620px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    min-height: auto;
  }

  #gameCanvas {
    height: auto;
    width: min(100%, 64svh);
  }
}

@media (max-width: 560px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .play-shell {
    width: 100%;
    max-width: 100%;
    padding-right: 10px;
    padding-left: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pills {
    justify-content: flex-start;
  }

  .game-layout,
  .stage-panel,
  .hud {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #gameCanvas {
    width: 100%;
    max-height: 62svh;
  }

  .hud h1 {
    font-size: clamp(26px, 8vw, 40px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }
}
