:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101316;
  color: #f4f4eb;
}

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

img,
canvas {
  -webkit-user-drag: none;
  user-drag: none;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(24, 177, 153, 0.18), transparent 42%),
    #101316;
}

button {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #f4ce55;
  color: #17150d;
  box-shadow: 0 3px 0 #946f1f;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

button:active,
button.active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #946f1f;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 760px) 280px;
  justify-content: center;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.cabinet {
  position: relative;
  width: min(760px, calc((100dvh - 32px) * 19 / 24));
  height: auto;
  min-height: 0;
  aspect-ratio: 19 / 24;
  overflow: hidden;
  border: 2px solid rgba(244, 244, 235, 0.16);
  border-radius: 8px;
  background: #171c20;
}

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

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr)) auto;
  gap: 8px;
  pointer-events: none;
}

.hud > div,
.hud button {
  border: 1px solid rgba(244, 244, 235, 0.15);
  border-radius: 8px;
  background: rgba(8, 11, 13, 0.72);
  backdrop-filter: blur(8px);
}

.hud > div {
  min-width: 0;
  padding: 7px 9px;
}

.hud span {
  display: block;
  color: #9baba8;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  overflow: hidden;
  color: #f4f4eb;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud button {
  min-width: 44px;
  padding: 0;
  color: #f4f4eb;
  pointer-events: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  background: rgba(7, 9, 11, 0.72);
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  color: #f4ce55;
  font-size: clamp(44px, 8vw, 96px);
  line-height: 0.9;
}

.overlay p {
  max-width: 520px;
  margin: 0;
  font-size: 18px;
}

.overlay .eyebrow {
  color: #70d9c2;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.touch-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: none;
  grid-template-columns: repeat(2, 64px);
  gap: 10px;
}

.touch-controls button {
  min-height: 58px;
  padding: 0;
  font-size: 20px;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 32px);
  min-height: 560px;
  border: 2px solid rgba(244, 244, 235, 0.16);
  border-radius: 8px;
  padding: 20px;
  background: rgba(16, 19, 22, 0.78);
}

.instructions h2 {
  margin: 0;
  color: #70d9c2;
  font-size: 28px;
}

.instructions p {
  margin: 8px 0 0;
  color: #c8d0cd;
  line-height: 1.5;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  border-top: 1px solid rgba(244, 244, 235, 0.12);
  padding-top: 10px;
}

dt {
  color: #f4ce55;
  font-weight: 900;
}

dd {
  margin: 3px 0 0;
}

.instructions .shelf {
  margin-top: auto;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 1fr;
    place-items: start center;
    padding: 10px;
  }

  .cabinet {
    width: min(100%, calc((100dvh - 20px) * 19 / 24));
    height: auto;
    min-height: 0;
    aspect-ratio: 19 / 24;
  }

  canvas {
    height: 100%;
    aspect-ratio: auto;
  }

  .touch-controls {
    display: grid;
  }

  .instructions {
    display: none;
  }
}

@media (max-width: 620px) {
  .cabinet {
    width: min(100%, calc((100dvh - 20px) * 19 / 24));
    aspect-ratio: 19 / 24;
  }

  .hud {
    top: 4px;
    left: 4px;
    right: 4px;
    grid-template-columns: repeat(4, minmax(0, 1fr)) 30px;
    gap: 3px;
  }

  .hud > div {
    padding: 2px 4px;
  }

  .hud span {
    font-size: 7px;
  }

  .hud .timer {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .hud strong {
    font-size: 10px;
  }

  .hud button {
    min-width: 30px;
    min-height: 30px;
    font-size: 12px;
  }

  .overlay {
    gap: 6px;
    padding: 8px;
  }

  .overlay h1 {
    font-size: 28px;
  }

  .overlay p {
    max-width: 280px;
    font-size: 11px;
    line-height: 1.2;
  }

  .overlay .eyebrow {
    font-size: 8px;
  }

  .overlay button {
    min-height: 30px;
    padding: 0 12px;
    font-size: 12px;
  }

  .touch-controls {
    right: 5px;
    bottom: 5px;
    grid-template-columns: repeat(2, 42px);
    gap: 5px;
  }

  .touch-controls button {
    min-height: 38px;
    font-size: 14px;
  }
}
