:root {
  --ink: #1b1320;
  --gold: #ffd23f;
  --red: #d7263d;
  --panel: rgba(24, 16, 38, 0.94);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07050d; color: #fff; font-family: "Bangers", system-ui, sans-serif; letter-spacing: 0.04em; overflow: hidden; }
#wrap { position: fixed; inset: 0; display: grid; place-items: center; }
#stage { position: fixed; inset: 0; overflow: hidden; }
.layer { position: absolute; display: block; }
#game { touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#shake { position: absolute; inset: 0; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; }
.overlay[hidden] { display: none; }
#menu { align-items: end; padding-bottom: 2.5%; }
#loading { background: #07050d; font-size: clamp(18px, 3vw, 36px); color: var(--gold); }
.menu-panel {
  background: var(--panel); border: 4px solid var(--gold); border-radius: 22px; box-shadow: 0 10px 0 #b3122e, 0 30px 60px rgba(0, 0, 0, 0.6);
  padding: clamp(10px, 1.6vw, 22px) clamp(14px, 2.4vw, 32px); width: min(92%, 860px); text-align: center;
}
#menu .menu-panel { width: min(96%, 980px); }
.menu-panel h2 { margin: 0 0 4px; font-size: clamp(22px, 3.4vw, 44px); color: var(--gold); text-shadow: 3px 3px 0 #b3122e; font-weight: 400; }
.hint { margin: 0 0 10px; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: clamp(11px, 1.2vw, 15px); opacity: 0.85; }
.fine { margin: 8px 0 0; font-family: system-ui, sans-serif; letter-spacing: 0; font-size: clamp(10px, 1vw, 13px); opacity: 0.7; }
.roster { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 10px; justify-content: safe center; }
.card {
  flex: 0 0 auto; width: clamp(74px, 9vw, 112px); background: #2a1f40; border: 3px solid transparent; border-radius: 14px; padding: 8px 6px 6px;
  color: #fff; font: inherit; font-size: clamp(12px, 1.2vw, 16px); cursor: pointer; position: relative; transition: transform 0.12s;
}
.card:hover { transform: translateY(-3px) rotate(-2deg); }
.card img { width: 100%; aspect-ratio: 1; border-radius: 50%; display: block; border: 3px solid var(--ink); background: #111; }
.card.you { border-color: var(--gold); background: #3a2556; }
.card.you::after { content: "YOU"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; padding: 1px 8px; border-radius: 8px; font-size: 13px; }
.card .del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #000a; color: #fff; font: inherit; cursor: pointer; line-height: 22px; padding: 0; }
.card span { display: block; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.btn {
  font: inherit; font-size: clamp(16px, 1.8vw, 24px); letter-spacing: 0.06em; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 20px;
  background: var(--gold); color: var(--ink); cursor: pointer; box-shadow: 0 5px 0 var(--ink); display: inline-flex; align-items: center;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.btn.big { background: var(--red); color: #fff; font-size: clamp(20px, 2.4vw, 32px); padding: 8px 34px; }
.btn.ghost { background: #3a2556; color: #fff; }
.btn:focus-visible, .card:focus-visible { outline: 3px solid #6fd0ff; outline-offset: 2px; }
.crop-panel { width: min(92%, 440px); max-height: 98%; overflow-y: auto; }
[hidden] { display: none !important; }
.crop-panel canvas { width: min(100%, 320px, 40vh); aspect-ratio: 1; border-radius: 16px; cursor: grab; touch-action: none; display: block; margin: 0 auto 8px; }
.row { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 6px 0; font-size: 18px; }
.row input[type="range"] { width: 60%; accent-color: var(--red); }
.row input[type="text"] { font: inherit; font-size: 18px; padding: 4px 10px; border-radius: 10px; border: 2px solid var(--gold); background: #15101f; color: #fff; width: 60%; }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #0008; cursor: pointer; }
.swatches button.on { border-color: var(--gold); transform: scale(1.15); }
.btn.small { font-size: 16px; padding: 4px 14px; }
.card img { clip-path: ellipse(38% 50%); border-radius: 0; border: 0; background: none; }
.cam { position: relative; width: min(100%, 360px, 48vh); aspect-ratio: 3 / 4; margin: 0 auto 8px; border-radius: 16px; overflow: hidden; background: #000; }
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card.locked img { filter: brightness(0) opacity(0.55); }
.card.locked { cursor: not-allowed; }
html, body { touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
.overlay { overflow-y: auto; padding: 8px; }
.menu-panel { max-height: calc(100dvh - 16px); overflow-y: auto; }
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: grid; position: fixed; inset: 0; z-index: 50; place-items: center; background: #07050d; color: #ffd23f; text-align: center; font-size: 28px; padding: 24px; }
  #rotate span { display: block; font-size: 64px; animation: tilt 1.6s ease-in-out infinite; }
}
@keyframes tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }
@media (max-height: 500px) {
  .menu-panel h2 { font-size: 22px; }
  .hint, .fine { font-size: 11px; margin-bottom: 4px; }
  .card { width: 64px; padding: 4px; }
  .btn { font-size: 15px; padding: 6px 12px; }
  .btn.big { font-size: 20px; padding: 6px 18px; }
  .crop-panel canvas { width: min(100%, 34vh); }
  .cam { width: min(100%, 38vh); }
}
