:root {
  color-scheme: light;
  --ink: #111;
  --red: #d71920;
  --glass: rgba(255, 255, 255, 0.92);
  --glass-edge: rgba(255, 255, 255, 0.95);
  --tray-bottom: 126px;
  --tray-height: 82px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: "Bungee", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

#image-backdrop {
  position: absolute;
  inset: 0;
  background: #fff;
  transition: background-color 320ms ease;
}

#image-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

#image-viewport.dragging {
  cursor: grabbing;
}

#scene {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  transform-origin: 0 0;
  will-change: transform;
}

#stage-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  transition: opacity 300ms ease;
}

#target-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 50%;
  outline: 0;
  background: transparent;
  pointer-events: auto;
  cursor: default;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
}

.hotspot:focus,
.hotspot:hover {
  outline: 0;
  background: transparent;
  cursor: default;
}

.found-ring {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

.found-ring svg {
  display: block;
  width: 100%;
  height: 100%;
}

.found-ring circle {
  fill: none;
  stroke: var(--red);
  stroke-width: 5;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  vector-effect: non-scaling-stroke;
  transform: rotate(-90deg);
  transform-origin: center;
  animation: draw-ring 1s linear forwards;
}

@keyframes draw-ring {
  to {
    stroke-dashoffset: 0;
  }
}

.glass {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.19),
    inset 0 1px rgba(255, 255, 255, 0.95);
}

.glass::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), transparent 48%, rgba(255, 255, 255, 0.15));
  content: "";
  clip-path: inset(0 round 30px);
  pointer-events: none;
}

.icon-button.glass::before,
.mode-button.glass::before {
  clip-path: circle(50%);
}

.glass > * {
  position: relative;
  z-index: 1;
}

.icon-button,
.mode-button,
.share-button,
.zoom button,
.carousel-arrow,
.modal-close,
.ad-panel > button {
  transition:
    background-color 200ms ease,
    box-shadow 200ms ease,
    transform 200ms ease,
    opacity 200ms ease;
}

.icon-button:hover,
.mode-button:hover,
.share-button:hover,
.zoom button:hover,
.carousel-arrow:hover {
  background-color: rgba(255, 255, 255, 0.97);
  transform: translateY(-2px);
}

.icon-button:active,
.mode-button:active,
.share-button:active,
.zoom button:active {
  transform: scale(0.96);
}

.topbar {
  position: absolute;
  z-index: 5;
  top: calc(14px + env(safe-area-inset-top));
  right: 18px;
  left: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

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

.icon-button,
.mode-button {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
}

.icon-button .material-symbols-rounded {
  font-size: 22px;
}

.mode-button {
  font-size: 13px;
}

.brand-logo {
  position: absolute;
  top: -5px;
  left: 50%;
  width: min(210px, 28vw);
  height: auto;
  max-height: 88px;
  object-fit: contain;
  pointer-events: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 4px 2px rgba(255, 255, 255, 0.5));
}

.zoom {
  position: absolute;
  z-index: 5;
  right: 3%;
  bottom: calc(var(--tray-bottom) + var(--tray-height) + 8px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 28px;
}

.zoom button {
  display: grid;
  width: 34px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 22px;
  background: transparent;
}

.zoom button .material-symbols-rounded {
  font-size: 21px;
}

.zoom .zoom-reset {
  width: 47px;
  border-right: 1px solid rgba(0, 0, 0, 0.16);
  border-left: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 0;
}

#zoom-readout {
  font-size: 7px;
  white-space: nowrap;
}

.share-button {
  position: absolute;
  z-index: 5;
  bottom: calc(var(--tray-bottom) + var(--tray-height) + 8px + env(safe-area-inset-bottom));
  left: 3%;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 26px;
  font-size: 9px;
}

.share-button .material-symbols-rounded {
  font-size: 17px;
}

.bottom {
  position: absolute;
  z-index: 4;
  right: 3%;
  bottom: calc(var(--tray-bottom) + env(safe-area-inset-bottom));
  left: 3%;
  min-height: var(--tray-height);
  padding: 6px 18px 8px;
  border-radius: 22px;
  transition: bottom 320ms ease, transform 320ms ease;
}

.prompt {
  position: relative;
  min-height: 20px;
  text-align: center;
  font-size: clamp(9px, 0.8vw, 13px);
}

.prompt b {
  font-weight: inherit;
}

.timer {
  position: absolute;
  top: 1px;
  right: 4px;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.carousel-wrap {
  position: relative;
}

.cards {
  display: flex;
  gap: 9px;
  height: 48px;
  overflow-x: auto;
  padding: 3px 26px 5px;
  scrollbar-width: none;
  scroll-behavior: smooth;
  touch-action: pan-x;
}

.cards::-webkit-scrollbar {
  display: none;
}

.card {
  position: relative;
  flex: 0 0 42px;
  height: 42px;
  padding: 2px 5px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: transform 180ms ease, background-color 180ms ease;
}

.card:hover {
  background: rgba(255, 255, 255, 0.38);
  transform: translateY(-3px);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card.done::after {
  position: absolute;
  right: 2px;
  bottom: -2px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  content: "✓";
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  animation: check-pop 280ms cubic-bezier(0.2, 1.5, 0.35, 1) both;
}

@keyframes check-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.carousel-arrow {
  position: absolute;
  z-index: 2;
  top: 7px;
  width: 24px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.5);
  font-family: system-ui, sans-serif;
  font-size: 21px;
}

.carousel-arrow.left {
  left: 0;
}

.carousel-arrow.right {
  right: 0;
}

.ad-panel {
  position: absolute;
  z-index: 4;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  display: none;
  width: min(810px, 74vw);
  min-height: 86px;
  padding: 14px 20px;
  border-radius: 16px;
  text-align: center;
  transform: translateX(-50%);
}

.ad-panel.open {
  display: block;
  animation: ad-enter 300ms ease both;
}

@keyframes ad-enter {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.ad-panel > button {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #111;
  color: #fff;
}

.ad-panel > button .material-symbols-rounded {
  font-size: 22px;
}

.ad-panel .adsbygoogle {
  width: 100%;
  min-height: 52px;
}

.game.ad-hidden {
  --tray-bottom: 24px;
}

.low-contrast #image-backdrop {
  background: #fffde9;
}

.low-contrast #stage-image {
  opacity: 0.85;
}

.overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: overlay-in 240ms ease both;
}

.overlay.hidden {
  display: none;
}

.overlay.closing {
  animation: overlay-out 220ms ease both;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlay-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.modal,
.loading-card {
  width: min(440px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  padding: 18px;
  border-radius: 20px;
  animation: modal-in 330ms cubic-bezier(0.2, 1.18, 0.35, 1) both;
}

.overlay.closing .modal {
  animation: modal-out 220ms ease both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modal-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

.modal-close {
  position: sticky;
  top: 0;
  z-index: 2;
  float: right;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
}

.modal h2 {
  margin: 4px 48px 18px 0;
  font-size: clamp(15px, 2.5vw, 21px);
  line-height: 1.2;
}

.modal h3 {
  margin: 24px 0 10px;
  font-size: 13px;
}

.modal p,
.modal label,
.modal table {
  font-size: 10px;
  line-height: 1.6;
}

.modal img.reference {
  display: block;
  width: min(210px, 70vw);
  height: min(205px, 42vh);
  margin: 16px auto;
  object-fit: contain;
}

.modal form {
  display: grid;
  gap: 12px;
}

.modal input,
.modal select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #999;
  border-radius: 12px;
  background: #fff;
}

.modal button.action,
.share-links a,
.share-links button {
  position: relative;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: #111;
  color: #fff;
  text-decoration: none;
  text-align: center;
  font-size: 9px;
  transition: transform 180ms ease, background-color 180ms ease;
}

.modal button.action:hover,
.share-links a:hover,
.share-links button:hover {
  background: var(--red);
  transform: translateY(-2px);
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 18px 0;
}

.ranking {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.ranking th,
.ranking td {
  padding: 8px 5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  text-align: left;
}

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

.stage-choice {
  overflow: hidden;
  padding: 0;
  border: 1px solid #ddd;
  border-radius: 14px;
  background: #fff;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.stage-choice:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.stage-choice img {
  display: block;
  width: 100%;
  height: 90px;
  object-fit: cover;
}

.stage-choice span {
  display: block;
  padding: 9px;
  font-size: 11px;
}

.loading-card {
  width: min(460px, 100%);
  text-align: center;
}

.loading-card video {
  display: block;
  width: min(330px, 72vw);
  height: min(300px, 45vh);
  margin: auto;
  border-radius: 18px;
  object-fit: contain;
}

.loading-fallback {
  display: none;
  width: min(250px, 60vw);
  height: 200px;
  margin: auto;
  object-fit: contain;
}

.loading-card p {
  font-size: 14px;
}

.progress {
  overflow: hidden;
  height: 5px;
  border-radius: 5px;
  background: #fff;
}

.progress i {
  display: block;
  width: 32%;
  height: 100%;
  background: var(--red);
  animation: loading-progress 1.45s ease-in-out infinite;
}

@keyframes loading-progress {
  from { transform: translateX(-120%); }
  to { transform: translateX(390%); }
}

@media (max-width: 700px) {
  :root {
    --tray-bottom: 112px;
    --tray-height: 92px;
  }

  .topbar {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    left: 10px;
  }

  .top-actions {
    gap: 5px;
  }

  .icon-button,
  .mode-button {
    width: 40px;
    height: 40px;
  }

  .icon-button .material-symbols-rounded {
    font-size: 21px;
  }

  .mode-button {
    font-size: 12px;
  }

  .brand-logo {
    top: 44px;
    width: min(160px, 43vw);
  }

  .bottom {
    right: 10px;
    left: 10px;
    padding: 7px 6px;
    border-radius: 20px;
  }

  .prompt {
    min-height: 26px;
    padding-right: 44px;
    padding-left: 44px;
    font-size: 8px;
  }

  .timer {
    top: 2px;
    right: 2px;
    font-size: 7px;
  }

  .cards {
    height: 51px;
    gap: 5px;
    padding: 4px 22px;
  }

  .card {
    flex-basis: 43px;
    height: 43px;
  }

  .carousel-arrow {
    width: 20px;
    height: 34px;
    font-size: 20px;
  }

  .ad-panel {
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    min-height: 82px;
    border-radius: 25px;
  }

  .ad-panel > button {
    top: 0;
    right: 50%;
    transform: translateX(50%);
  }

  .zoom {
    right: 12px;
    bottom: calc(var(--tray-bottom) + var(--tray-height) + 8px + env(safe-area-inset-bottom));
  }

  .zoom button {
    width: 31px;
    height: 31px;
  }

  .zoom .zoom-reset {
    width: 43px;
  }

  .zoom button .material-symbols-rounded {
    font-size: 20px;
  }

  #zoom-readout {
    font-size: 8px;
  }

  .share-button {
    bottom: calc(var(--tray-bottom) + var(--tray-height) + 8px + env(safe-area-inset-bottom));
    left: 12px;
    min-height: 36px;
    padding: 0 8px;
  }

  .share-label {
    display: none;
  }

  .game.ad-hidden {
    --tray-bottom: 14px;
  }

  .stage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .top-actions {
    gap: 5px;
  }

  .icon-button,
  .mode-button {
    width: 36px;
    height: 36px;
  }

  .brand-logo {
    top: 42px;
    width: 150px;
  }

  .modal {
    padding: 18px;
  }
}

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