:root {
  --bg-a: #2c2716;
  --bg-b: #0d1209;
  --shell: #b4a37d;
  --shell-shadow: #6b5a39;
  --screen: #8ea76e;
  --screen-deep: #415333;
  --screen-ink: #152011;
  --ghost: #d9dfd0;
  --ghost-stall: #eff3eb;
  --egg: #f0cf76;
  --text: #10140d;
  --text-soft: rgba(16, 20, 13, 0.72);
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 222, 153, 0.22), transparent 34%),
    radial-gradient(circle at 20% 100%, rgba(145, 188, 108, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg-a), var(--bg-b));
  color: var(--text);
  font-family: "Courier New", "Noto Sans TC", monospace;
}

body {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  min-height: 100svh;
  min-height: 100dvh;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

button {
  font: inherit;
  color: inherit;
}

.cabinet {
  width: min(100vw, 980px);
  height: min(100svh, 760px);
  height: min(100dvh, 760px);
  display: grid;
  place-items: center;
}

.device {
  width: min(100%, 920px);
  height: min(100%, 720px);
  padding: 18px;
  border-radius: 30px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 248, 212, 0.22), transparent 12%),
    linear-gradient(180deg, #c3b48d, #8c7a54);
  box-shadow:
    inset 0 2px 0 rgba(255, 245, 205, 0.54),
    inset 0 -6px 16px rgba(56, 44, 24, 0.34),
    0 26px 60px rgba(0, 0, 0, 0.36);
}

.device::before,
.device::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.device::before {
  inset: 8px;
  border-radius: 24px;
  border: 2px solid rgba(79, 61, 29, 0.28);
}

.device::after {
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 10%, transparent 90%, rgba(0, 0, 0, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 16%, transparent 84%, rgba(0, 0, 0, 0.09));
  border-radius: 30px;
}

.device-chrome {
  position: absolute;
  top: 12px;
  left: 20px;
  right: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 2;
  pointer-events: none;
}

.speaker,
.indicator {
  display: block;
  border-radius: 999px;
  background: rgba(79, 61, 29, 0.42);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
}

.speaker {
  width: 92px;
  height: 6px;
}

.indicator {
  width: 18px;
  height: 18px;
  background:
    radial-gradient(circle at 45% 35%, rgba(255, 238, 179, 0.64), rgba(168, 50, 37, 0.88) 52%, rgba(86, 19, 13, 0.96));
}

.screen-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  border: 8px solid #665637;
  background:
    linear-gradient(180deg, rgba(232, 223, 184, 0.18), transparent 12%),
    linear-gradient(180deg, #6f6240, #4b4027);
  box-shadow:
    inset 0 1px 0 rgba(255, 249, 214, 0.22),
    inset 0 -10px 22px rgba(0, 0, 0, 0.28);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hud,
.overlay {
  position: absolute;
  inset: 0;
}

.hud {
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.clock-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding:
    max(18px, env(safe-area-inset-top))
    12px
    0;
}

.clock-slot {
  display: grid;
  justify-items: center;
  gap: 6px;
  opacity: 0.38;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
  filter: grayscale(1);
}

.clock-slot.active {
  opacity: 1;
  filter: none;
}

.clock-slot.paused {
  animation: pausedPulse 460ms steps(2, end) infinite;
}

.clock-title {
  min-height: 2.5em;
  padding: 0 2px;
  text-align: center;
  font-size: clamp(10px, 1.05vw, 14px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(248, 252, 241, 0.96);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.42),
    0 0 6px rgba(0, 0, 0, 0.28);
}

.clock-face {
  position: relative;
  width: clamp(36px, 6.4vw, 56px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid rgba(21, 32, 17, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.06)),
    linear-gradient(180deg, rgba(171, 193, 143, 0.88), rgba(107, 128, 86, 0.94));
  box-shadow:
    inset 0 0 0 4px rgba(227, 240, 210, 0.22),
    inset 0 -3px 0 rgba(27, 36, 20, 0.18);
}

.clock-face::before,
.clock-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.clock-face::before {
  background:
    linear-gradient(90deg, transparent 45%, rgba(21, 32, 17, 0.14) 45%, rgba(21, 32, 17, 0.14) 55%, transparent 55%),
    linear-gradient(180deg, transparent 45%, rgba(21, 32, 17, 0.14) 45%, rgba(21, 32, 17, 0.14) 55%, transparent 55%);
}

.clock-face::after {
  inset: 8px;
  border: 2px solid rgba(21, 32, 17, 0.2);
}

.clock-hand,
.clock-core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% calc(100% - 2px);
}

.clock-hand {
  width: 4px;
  border-radius: 0;
  background: rgba(12, 18, 9, 0.96);
  margin-left: 0;
  margin-top: 0;
  box-shadow: 0 0 0 1px rgba(245, 251, 236, 0.1);
  transform-origin: 50% 100%;
}

.clock-hand.slow {
  height: 28%;
}

.clock-hand.fast {
  height: 36%;
  background: rgba(42, 50, 33, 0.92);
}

.clock-core {
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  background: rgba(15, 22, 12, 0.98);
  box-shadow: 0 0 0 2px rgba(233, 243, 218, 0.12);
}

.status-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding:
    0
    16px
    max(16px, env(safe-area-inset-bottom));
}

.status-chip {
  min-height: 38px;
  max-width: calc(100% - 62px);
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  border: 3px solid rgba(21, 32, 17, 0.82);
  background:
    linear-gradient(180deg, rgba(177, 198, 146, 0.92), rgba(98, 122, 75, 0.94));
  color: rgba(15, 19, 12, 0.92);
  font-size: clamp(10px, 1.6vw, 14px);
  line-height: 1.15;
  letter-spacing: 0.05em;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.16),
    0 6px 16px rgba(0, 0, 0, 0.12);
}

.restart-btn,
.play-btn {
  border: 3px solid rgba(21, 32, 17, 0.82);
  background:
    linear-gradient(180deg, rgba(197, 213, 171, 0.92), rgba(106, 129, 82, 0.96));
  color: rgba(15, 19, 12, 0.92);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.16),
    0 8px 18px rgba(0, 0, 0, 0.14);
}

.restart-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.restart-btn.holding {
  transform: scale(0.96);
  filter: brightness(0.96);
}

.restart-btn.hold-ready {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.16),
    0 8px 18px rgba(0, 0, 0, 0.14),
    0 0 0 3px rgba(244, 252, 222, 0.32);
}

.restart-btn span {
  width: 16px;
  height: 16px;
  border: 4px solid rgba(15, 19, 12, 0.9);
  border-right-color: transparent;
  border-radius: 50%;
  position: relative;
  transform: rotate(-24deg);
}

.restart-btn span::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -6px;
  width: 0;
  height: 0;
  border-left: 8px solid rgba(15, 19, 12, 0.9);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: rotate(12deg);
}

.overlay {
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 13, 8, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  width: min(100%, 440px);
  padding: 20px 18px;
  border: 4px solid rgba(21, 32, 17, 0.82);
  background:
    linear-gradient(180deg, rgba(204, 221, 180, 0.92), rgba(118, 142, 91, 0.94));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 22px 44px rgba(0, 0, 0, 0.16);
  text-align: center;
}

.eyebrow {
  font-size: clamp(11px, 1.8vw, 14px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.title {
  margin: 10px 0 0;
  font-size: clamp(24px, 4.6vw, 42px);
  line-height: 1.05;
}

.title.small {
  font-size: clamp(20px, 4vw, 34px);
}

.subtitle {
  margin: 12px 0 0;
  font-size: clamp(12px, 2vw, 16px);
  line-height: 1.5;
  color: var(--text-soft);
}

.result-stats,
.result-best {
  margin: 10px 0 0;
  font-size: clamp(12px, 2vw, 16px);
  line-height: 1.45;
}

.result-stats {
  color: rgba(16, 20, 13, 0.92);
  font-weight: 700;
}

.result-best {
  color: rgba(16, 20, 13, 0.74);
}

.play-btn {
  margin-top: 18px;
  min-width: 148px;
  min-height: 46px;
  padding: 10px 16px;
  pointer-events: auto;
}

@keyframes pausedPulse {
  0%,
  49% {
    filter: grayscale(0.2) brightness(1);
  }

  50%,
  100% {
    filter: grayscale(0.24) brightness(1.28);
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .cabinet {
    width: 100vw;
    height: 100svh;
    height: 100dvh;
  }

  .device {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: 0;
  }

  .device::before,
  .device::after {
    border-radius: 0;
  }

  .device-chrome {
    top: max(12px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
  }

  .screen-frame {
    border-radius: 0;
  }

  .clock-title {
    font-size: clamp(9px, 2.2vw, 12px);
  }
}
