:root {
  color-scheme: dark;
  --bg: #04040a;
  --panel: rgba(5, 10, 20, 0.82);
  --cyan: #31f2ff;
  --magenta: #ff4fd8;
  --lime: #b0ff57;
  --orange: #ff9a3c;
  --shield: #4db7ff;
  --text: #e7fbff;
  --muted: rgba(231, 251, 255, 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(49, 242, 255, 0.09), transparent 36%),
    radial-gradient(circle at bottom right, rgba(255, 79, 216, 0.08), transparent 34%),
    linear-gradient(180deg, #04040a 0%, #05060d 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
  overflow: auto;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.topbar,
.score-card,
.guide-card,
.side-panel,
.stage-card {
  border: 1px solid rgba(49, 242, 255, 0.22);
  background: var(--panel);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 18px rgba(49, 242, 255, 0.08), inset 0 0 24px rgba(49, 242, 255, 0.04);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
}

.brand {
  font-size: clamp(1.3rem, 2vw, 2rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(49, 242, 255, 0.58);
}

.subbrand,
.hud-meta {
  color: var(--muted);
}

.hud-meta {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  text-align: right;
}

.status-label {
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 28ch;
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 340px);
  gap: 16px;
  align-items: stretch;
  overflow: hidden;
}

.stage-card {
  min-height: 0;
  padding: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.game-stage {
  position: relative;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 10 / 16;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(176, 255, 87, 0.18);
  background:
    linear-gradient(rgba(49, 242, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(49, 242, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(255, 79, 216, 0.08), transparent 45%),
    #020308;
  background-size: 44px 44px, 44px 44px, auto, auto;
  box-shadow: inset 0 0 40px rgba(49, 242, 255, 0.06), 0 0 32px rgba(255, 79, 216, 0.07);
}

.camera-layer,
#webcam,
#gameCanvas,
#handCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-layer {
  overflow: hidden;
  opacity: 0.48;
  filter: saturate(1.18) contrast(1.08) brightness(1.04);
  z-index: 0;
}

#webcam {
  object-fit: cover;
  transform: scaleX(-1);
}

#gameCanvas {
  z-index: 1;
  pointer-events: none;
}

#handCanvas {
  z-index: 2;
  pointer-events: none;
}

.center-message {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: min(92%, 560px);
  padding: 24px;
  border-radius: 24px;
  text-align: center;
  background: rgba(4, 7, 16, 0.82);
  border: 1px solid rgba(255, 79, 216, 0.28);
  box-shadow: 0 0 26px rgba(255, 79, 216, 0.14), inset 0 0 20px rgba(49, 242, 255, 0.05);
}

.center-message.hidden {
  display: none;
}

.center-message h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  color: var(--magenta);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.center-message p {
  margin: 0 0 16px;
  line-height: 1.6;
  color: var(--muted);
}

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

.emoji-option {
  border: 1px solid rgba(49, 242, 255, 0.22);
  background: rgba(6, 10, 18, 0.82);
  border-radius: 16px;
  padding: 10px 0;
  font-size: 1.7rem;
  cursor: pointer;
}

.emoji-option.selected {
  border-color: rgba(176, 255, 87, 0.9);
  box-shadow: 0 0 18px rgba(176, 255, 87, 0.18), inset 0 0 16px rgba(176, 255, 87, 0.08);
  background: rgba(10, 20, 16, 0.92);
}

#startButton {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  color: #041118;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 0 22px rgba(49, 242, 255, 0.22);
}

.side-panel {
  padding: 14px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.score-card {
  padding: 18px 16px;
  display: grid;
  gap: 8px;
}

.score-card-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
}

.score-card-value {
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  font-weight: 900;
  line-height: 0.95;
  color: var(--cyan);
  text-shadow: 0 0 22px rgba(49, 242, 255, 0.42);
}

.guide-card {
  height: 100%;
  max-height: 100%;
  overflow: auto;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.gesture-item {
  display: grid;
  gap: 4px;
}

.gesture-item strong {
  color: var(--cyan);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.gesture-item span {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .side-panel {
    order: 2;
  }

  .game-stage {
    width: min(100%, calc((100dvh - 260px) * 10 / 16));
    height: auto;
    max-height: 78dvh;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-meta {
    align-items: flex-start;
    text-align: left;
  }

  .game-stage {
    width: min(100%, 88vw);
    height: auto;
    max-height: 70dvh;
  }
}
