:root {
  color-scheme: light;
  --ui-cream: #fff6e1;
  --ui-brown: #6b3f1f;
  --ui-orange: #d94a1e;
  --ui-border-brown: rgba(92, 55, 24, 0.28);
  --score-bg: rgba(255, 246, 225, 0.94);
  --score-border: rgba(92, 55, 24, 0.28);
  --score-label: #6b3f1f;
  --score-number: #d94a1e;
  --score-shadow: rgba(0, 0, 0, 0.18);
  --trail-color: rgba(255, 246, 225, 0.26);
  --spark-color: #fff7cf;
  --pulse-color: rgba(255, 247, 207, 0.56);
  --ball-white: #f7f7ef;
  --ball-orange: #e9542a;
  --ball-yellow: #f5c12e;
  --ball-blue: #2f9fe3;
  --ball-outline: rgba(72, 50, 30, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #f4f1eb;
}

body {
  min-width: 280px;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  overscroll-behavior: none;
}

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

.page-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 2vh 0;
}

.scene {
  position: relative;
  width: min(96vw, 1672px, calc(96vh * 1672 / 941));
  width: min(96vw, 1672px, calc(96svh * 1672 / 941));
  aspect-ratio: 1672 / 941;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: clamp(12px, 2vw, 30px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);
  background: #1f3a0d;
  isolation: isolate;
}

.scene__image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}

.rabbit-anchors {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.clock-panel {
  position: absolute;
  left: 50%;
  bottom: clamp(22px, 4.8%, 58px);
  z-index: 12;
  width: min(58%, 720px);
  padding: clamp(10px, 1.4vw, 20px) clamp(16px, 2vw, 30px);
  border: 1px solid rgba(255, 246, 225, 0.22);
  border-radius: clamp(16px, 2vw, 30px);
  background: rgba(8, 22, 8, 0.24);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  color: rgba(255, 246, 225, 0.9);
  text-align: center;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.58);
  transform: translateX(-50%);
  backdrop-filter: blur(3px) saturate(1.1);
  -webkit-backdrop-filter: blur(3px) saturate(1.1);
  pointer-events: none;
}

.clock-panel__time {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.08em;
  font-family: Impact, Haettenschweiler, "Arial Narrow", system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 0.88;
}

.clock-panel__hm {
  font-size: clamp(52px, 8.4vw, 142px);
  font-variant-numeric: tabular-nums;
}

.clock-panel__seconds {
  font-size: clamp(18px, 2.8vw, 48px);
  font-variant-numeric: tabular-nums;
  opacity: 0.76;
  transform: translateY(-0.1em);
  transition: opacity 160ms ease, transform 160ms ease;
}

.clock-panel__seconds.is-ticking {
  opacity: 1;
  transform: translateY(-0.18em);
}

.clock-panel__date {
  margin-top: clamp(4px, 0.6vw, 8px);
  font-size: clamp(12px, 1.35vw, 22px);
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0.88;
}

.clock-panel__watch {
  margin-top: clamp(3px, 0.5vw, 7px);
  font-size: clamp(10px, 1vw, 16px);
  font-weight: 700;
  opacity: 0.72;
}

.ball-shadow {
  position: absolute;
  z-index: 14;
  width: calc(var(--shadow-width, 46) / 1672 * 100%);
  height: calc(var(--shadow-height, 13) / 941 * 100%);
  min-width: 12px;
  min-height: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, var(--shadow-opacity, 0.2));
  filter: blur(clamp(2px, 0.32vw, 5px));
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: left, top, width, height, opacity;
}

.scene-effects {
  position: absolute;
  inset: 0;
  z-index: 15;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.motion-trail {
  fill: none;
  stroke: var(--trail-color);
  stroke-width: var(--trail-width, 12);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: var(--trail-opacity, 0.8);
  filter: url("#trailBlur");
}

.motion-trail--soft {
  stroke-width: calc(var(--trail-width, 12) * 1.8);
  opacity: calc(var(--trail-opacity, 0.8) * 0.34);
}

.beach-ball {
  position: absolute;
  z-index: 16;
  width: calc(64 / 1672 * 100%);
  min-width: 38px;
  max-width: 72px;
  aspect-ratio: 1;
  transform:
    translate(-50%, -50%)
    rotate(var(--ball-rotation, 0deg))
    scale(var(--ball-scale-x, 1), var(--ball-scale-y, 1));
  transform-origin: center;
  pointer-events: none;
  will-change: left, top, transform;
}

.beach-ball svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.beach-ball.is-squashing {
  animation: ball-squash 100ms ease-out;
}

.rabbit-name {
  position: absolute;
  z-index: 18;
  max-width: var(--label-max-width);
  min-width: 54px;
  padding: 5px 9px;
  overflow: hidden;
  border: 1px solid rgba(92, 55, 24, 0.26);
  border-radius: 999px;
  background: rgba(255, 246, 225, 0.78);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
  color: #4f2e16;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: clamp(12px, 1.05vw, 17px);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  transform: var(--label-transform);
  backdrop-filter: blur(2px) saturate(1.08);
  -webkit-backdrop-filter: blur(2px) saturate(1.08);
}

.rabbit-name:focus {
  overflow: visible;
  text-overflow: clip;
}

.rabbit-name:focus-visible {
  outline: 2px solid var(--ui-orange);
  outline-offset: 2px;
  background: rgba(255, 246, 225, 0.92);
}

.rabbit-name:empty::before {
  content: attr(data-placeholder);
  color: rgba(79, 46, 22, 0.58);
}

.score-chip {
  position: absolute;
  left: calc(56 / 1672 * 100%);
  top: calc(56 / 941 * 100%);
  z-index: 20;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
  min-height: clamp(34px, calc(52 / 941 * 100%), 52px);
  padding: clamp(7px, 0.66vw, 11px) clamp(11px, 1.08vw, 18px);
  border: 1px solid var(--score-border);
  border-radius: 999px;
  background: var(--score-bg);
  box-shadow: 0 6px 18px var(--score-shadow);
  color: var(--score-label);
  font-family: "Comic Sans MS", "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: clamp(14px, 1.55vw, 26px);
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
}

.score-chip__number {
  color: var(--score-number);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.035em;
}

.score-chip.is-bumping {
  animation: score-bump 220ms ease-out;
}

.audio-chip {
  position: absolute;
  right: calc(32 / 1672 * 100%);
  bottom: calc(32 / 941 * 100%);
  z-index: 22;
  display: inline-flex;
  align-items: center;
  gap: clamp(4px, 0.48vw, 8px);
  padding: clamp(6px, 0.48vw, 8px) clamp(7px, 0.6vw, 10px);
  border: 1px solid rgba(92, 55, 24, 0.24);
  border-radius: 999px;
  background: rgba(255, 246, 225, 0.88);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  color: var(--ui-brown);
  font-family: "Comic Sans MS", "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: clamp(11px, 1.05vw, 17px);
  line-height: 1;
  transition: opacity 140ms ease;
  white-space: nowrap;
}

.audio-chip[data-enabled="false"] {
  opacity: 0.72;
}

.audio-chip button,
.audio-chip output {
  font: inherit;
}

.audio-chip button {
  min-width: 2em;
  min-height: 2em;
  padding: 0.35em 0.5em;
  border: 0;
  border-radius: 999px;
  color: var(--ui-brown);
  background: rgba(255, 255, 255, 0.48);
  cursor: pointer;
}

.audio-chip button:hover {
  background: rgba(255, 255, 255, 0.78);
}

.audio-chip button:active {
  transform: translateY(1px);
}

.audio-chip button:focus-visible {
  outline: 2px solid var(--ui-orange);
  outline-offset: 2px;
}

.audio-toggle {
  min-width: 5.8em;
}

.audio-volume-value {
  min-width: 3.2em;
  color: var(--ui-orange);
  font-weight: 800;
  text-align: center;
}

.impact-pulse {
  fill: none;
  stroke: var(--pulse-color);
  stroke-width: 3;
  transform-box: fill-box;
  transform-origin: center;
  animation: impact-pulse 360ms ease-out forwards;
}

.impact-ray {
  stroke: var(--spark-color);
  stroke-width: 4;
  stroke-linecap: round;
  animation: impact-ray 180ms ease-out forwards;
}

.impact-tap {
  fill: none;
  stroke: rgba(255, 247, 207, 0.72);
  stroke-width: 4;
  stroke-linecap: round;
  animation: impact-tap 260ms ease-out forwards;
}

.debug-label {
  display: none;
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  padding: 6px 12px;
  border: 2px solid #777;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #666;
  font-weight: 800;
}

.scene.is-debug .debug-label {
  display: block;
}

.debug-anchor {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #ff2d55;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}

.debug-box {
  position: absolute;
  border: 1px dashed #ff2d55;
}

@keyframes score-bump {
  50% {
    transform: translateY(-2px) scale(1.08);
  }
}

@keyframes ball-squash {
  45% {
    transform:
      translate(-50%, -50%)
      rotate(var(--ball-rotation, 0deg))
      scale(1.15, 0.88);
  }
}

@keyframes impact-pulse {
  from {
    opacity: 0.9;
    transform: scale(0.55);
  }
  to {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes impact-ray {
  from {
    opacity: 1;
    stroke-dasharray: 0 30;
  }
  to {
    opacity: 0;
    stroke-dasharray: 22 30;
  }
}

@keyframes impact-tap {
  from {
    opacity: 0.85;
    stroke-dashoffset: 24;
  }
  to {
    opacity: 0;
    stroke-dashoffset: 0;
  }
}

@media (max-width: 700px) {
  .clock-panel {
    width: min(76vw, 520px);
    bottom: 18px;
  }

  .clock-panel__hm {
    font-size: clamp(42px, 14vw, 86px);
  }

  .rabbit-name {
    padding: 4px 7px;
    font-size: 12px;
  }

  .audio-chip {
    right: 12px;
    bottom: 12px;
    gap: 5px;
    padding: 6px 7px;
    font-size: 13px;
  }

  .audio-chip button {
    padding: 5px 7px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .audio-chip {
    top: 12px;
    right: 12px;
    bottom: auto;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  html,
  body {
    height: 100%;
  }

  body {
    overflow: hidden;
  }

  .page-shell {
    display: flex;
    min-height: 100%;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    scroll-behavior: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .page-shell::-webkit-scrollbar {
    display: none;
  }

  .scene {
    width: max(100vw, calc(100svh * 1672 / 941));
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }

  .score-chip {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    font-size: 15px;
  }

  .audio-chip {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .clock-panel {
    position: fixed;
    left: 50vw;
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 62px));
    width: min(82vw, 520px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .motion-trail,
  .motion-trail--soft {
    opacity: 0.08;
  }

  .score-chip.is-bumping,
  .beach-ball.is-squashing,
  .impact-ray,
  .impact-tap {
    animation: none;
  }

  .impact-pulse {
    animation-duration: 500ms;
    opacity: 0.35;
  }

  .audio-chip {
    transition: none;
  }

  .clock-panel__seconds {
    transition: none;
  }
}

@media (forced-colors: active) {
  .score-chip,
  .rabbit-name,
  .clock-panel,
  .audio-chip,
  .audio-chip button {
    border: 1px solid CanvasText;
  }
}
