* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #111;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.score {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(60vw, 440px);
  gap: 6px 14px;
  padding: 10px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  font-size: 22px;
}

.score b { font-variant-numeric: tabular-nums; }

.score .bump { display: inline-block; animation: bump 0.4s ease-out; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: #ffd84d; }
  100% { transform: scale(1); }
}

#status {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(220, 60, 60, 0.75);
  font-size: 15px;
  white-space: nowrap;
}

#status:empty { display: none; }

.tools {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.tools button {
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

#diag {
  position: absolute;
  top: 64px;
  left: 16px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.65);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

#diag[hidden], #toast[hidden] { display: none; }

#toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 18px;
}

.tools button { white-space: nowrap; }

#btn-sound {
  background: #ffd84d;
  color: #3a1a00;
  font-weight: 700;
}

@media (max-width: 600px) {
  .score { top: auto; bottom: 64px; right: 50%; transform: translateX(50%); }
  .tools { left: 50%; transform: translateX(-50%); }
  .tools .lbl { display: none; }
  .tools button { padding: 8px 14px; font-size: 18px; }
  #status {
    top: 66px;
    width: max-content;
    max-width: calc(100% - 32px);
    white-space: normal;
    text-align: center;
  }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 14px;
  text-align: center;
}

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 30% 20%, #ff9a3c 0%, #d9472b 45%, #4a1420 100%);
}

#overlay[hidden] { display: none; }

.card {
  width: 100%;
  max-width: 440px;
  padding: 28px 24px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
}

.logo { font-size: 48px; }

h1 { margin: 8px 0; font-size: 34px; }

.card ol {
  margin: 16px 0;
  padding-left: 20px;
  text-align: left;
  line-height: 1.5;
}

#start {
  margin-top: 8px;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  background: #ffd84d;
  color: #3a1a00;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

#start:disabled { opacity: 0.6; cursor: wait; }

#msg { min-height: 1.4em; }

.small { font-size: 13px; opacity: 0.8; }

kbd {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
}
