* {
  box-sizing: border-box;
}

:root {
  --bg: #0f172a; /* slate-900 */
  --panel: #111827; /* gray-900 */
  --panel-2: #0b1220; /* darker */
  --text: #e5e7eb; /* gray-200 */
  --muted: #9ca3af; /* gray-400 */
  --primary: #22d3ee; /* cyan-400 */
  --accent: #a855f7; /* purple-500 */
  --success: #22c55e; /* green-500 */
  --danger: #ef4444; /* red-500 */
  --warning: #f59e0b; /* amber-500 */
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1000px 600px at 10% 0%, rgba(168,85,247,0.2), transparent),
              radial-gradient(800px 500px at 100% 0%, rgba(34,211,238,0.18), transparent),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app-header {
  padding: 24px 24px 8px;
}
.app-header h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  padding: 12px 24px 24px;
}

.camera-panel, .game-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}
#webcam, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#overlay { pointer-events: none; }

/* Mirror only the video element; the canvas drawing is mirrored in code */
#webcam {
  transform: scaleX(-1);
}

.gesture-pill {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(17,24,39,0.8);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.camera-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
}
.label { color: var(--muted); margin-right: 6px; }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

button.primary {
  background: linear-gradient(90deg, var(--accent), var(--primary));
  color: #0b1020;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}
button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.countdown {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  background: rgba(168,85,247,0.2);
  border: 1px solid rgba(168,85,247,0.4);
}
.hidden { display: none; }

.status-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px;
}
.card-title {
  color: var(--muted);
  font-size: 12px;
}
.big-emoji {
  font-size: 56px;
  margin: 8px 0 4px;
}
.card-text { color: var(--text); }
.result .result-text {
  font-weight: 800;
  font-size: 18px;
}
.score { color: var(--muted); margin-top: 6px; }

.log-panel {
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 10px;
}
.log-header {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.log-list {
  display: flex;
  flex-direction: column-reverse; /* newest first */
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.log-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.log-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.log-vs { color: var(--muted); }

.app-footer {
  padding: 12px 24px 18px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
