/* =========================================================
   Circle Game – style.css
   Dark neon UI inspired by AR / cyberpunk aesthetics
   ========================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --cyan:    #00f5ff;
  --green:   #00ff88;
  --gold:    #ffd700;
  --red:     #ff3355;
  --bg:      #0a0a0f;
  --panel:   rgba(10, 10, 20, 0.85);
  --border:  rgba(0, 245, 255, 0.25);
  --font:    'Segoe UI', system-ui, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: #e0e8ff;
  font-family: var(--font);
  overflow: hidden;
}

/* ── App root ─────────────────────────────────────── */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Camera container ────────────────────────────── */
#camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  transform: scaleX(-1); /* mirror for natural selfie feel */
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  /* deliberately NOT mirrored – JS handles the coordinate flip */
  touch-action: none; /* prevent scroll/pan while drawing on mobile */
}

/* ── HUD (top bar) ───────────────────────────────── */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
  z-index: 10;
}

#title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
}

/* title row holds the title + action buttons */
#title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#bottom-shape-controls {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 11;
}

/* Gamemode button */
#gamemode-btn {
  flex-shrink: 0;
  height: 32px;
  min-width: 70px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  letter-spacing: 0.5px;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
#gamemode-btn:hover {
  background: rgba(0, 245, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.3);
}
#gamemode-btn:active { transform: scale(0.94); }

/* Gamemode dialog */
#gamemode-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.25s ease;
  padding: 20px;
}

#gamemode-card {
  position: relative;
  background: rgba(8, 8, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 26px 22px;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.22);
  backdrop-filter: blur(16px);
  animation: slide-up 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

#gamemode-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
  letter-spacing: 0.5px;
  padding-right: 32px;
}

#gamemode-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #8aa;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}
#gamemode-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
}

.gamemode-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: #cdd;
  font-size: 0.88rem;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.gamemode-option:hover {
  background: rgba(0, 245, 255, 0.06);
  border-color: var(--border);
}
.gamemode-option.active {
  background: rgba(0, 245, 255, 0.1);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.2);
}
.gamemode-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.gamemode-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gamemode-info strong {
  color: #e0e8ff;
  font-size: 0.92rem;
}
.gamemode-desc {
  font-size: 0.78rem;
  color: #8899aa;
  line-height: 1.4;
}

/* Shape selector */
#shape-selector {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 3px 6px;
  backdrop-filter: blur(6px);
}

.shape-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 1rem;
  color: #e0e8ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.shape-btn:hover {
  background: rgba(0, 245, 255, 0.15);
}
.shape-btn:active { transform: scale(0.9); }
.shape-btn.active {
  background: rgba(0, 245, 255, 0.25);
  box-shadow: 0 0 8px rgba(0, 245, 255, 0.4);
}



/* (?) help button in HUD */
#help-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--cyan);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
#help-btn:hover {
  background: rgba(0, 245, 255, 0.18);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.45);
}
#help-btn:active { transform: scale(0.94); }

#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  opacity: 0.9;
}

#status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
  transition: background 0.3s;
}

/* status dot colours */
#status-dot[data-type="good"]    { background: var(--green);  box-shadow: 0 0 8px var(--green);  }
#status-dot[data-type="active"]  { background: var(--red);    box-shadow: 0 0 8px var(--red);    animation: dot-pulse 0.8s ease-in-out infinite; }
#status-dot[data-type="warn"]    { background: var(--gold);   box-shadow: 0 0 8px var(--gold);   }
#status-dot[data-type="error"]   { background: var(--red);    }
#status-dot[data-type="info"]    { background: var(--cyan);   box-shadow: 0 0 8px var(--cyan);   }
#status-dot[data-type="loading"] { background: #aaa;          animation: dot-pulse 1.2s ease-in-out infinite; }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Instruction panel (bottom-left) ─────────────── */
#instructions-panel {
  position: absolute;
  bottom: 80px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.inst-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  backdrop-filter: blur(6px);
}

.inst-icon { font-size: 1.1rem; }

/* ── Button controls ─────────────────────────────── */
#btn-controls {
  position: absolute;
  bottom: max(78px, calc(env(safe-area-inset-bottom) + 54px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10;
}

.ctrl-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--cyan);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 24px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s, box-shadow 0.2s;
}

.ctrl-btn:hover {
  background: rgba(0, 245, 255, 0.15);
  box-shadow: 0 0 14px rgba(0, 245, 255, 0.4);
}

.ctrl-btn:active { transform: scale(0.97); }

#btn-score  { color: var(--gold);  border-color: rgba(255, 215, 0, 0.35); }
#btn-reset  { color: #aaa;         border-color: rgba(170,170,170,0.2);   }

/* ── Score overlay ───────────────────────────────── */
#score-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.3s ease;
  padding: 16px;
  overflow-y: auto;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#score-card {
  position: relative;
  background: rgba(8, 8, 18, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 380px;
  width: 90vw;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.2);
  backdrop-filter: blur(16px);
  animation: slide-up 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

#score-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #8aa;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}
#score-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* preview canvas */
#preview-canvas {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.5);
}

/* score number */
#score-value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

#score-number {
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  transition: color 0.5s;
  text-shadow: 0 0 20px currentColor;
}

#score-percent {
  font-size: 2rem;
  font-weight: 600;
  opacity: 0.8;
}

#score-message {
  font-size: 1rem;
  text-align: center;
  color: #bcd;
  letter-spacing: 0.5px;
}

/* detail bars */
#score-details {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 80px 1fr 42px;
  align-items: center;
  gap: 10px;
}

.detail-label {
  font-size: 0.78rem;
  color: #8899aa;
  text-align: right;
}

.detail-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.detail-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  box-shadow: 0 0 8px var(--cyan);
  transition: width 0.9s cubic-bezier(0.23, 1, 0.32, 1);
}

.detail-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan);
}

/* high score row */
#high-score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

#high-score-label {
  font-weight: 600;
}

#high-score-value {
  font-weight: 800;
}

/* score action buttons row */
#score-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

/* try-again button */
#try-again-btn {
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 24px;
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

#try-again-btn:hover {
  background: rgba(0, 245, 255, 0.12);
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.35);
}

/* share button */
#share-btn {
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 24px;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

#share-btn:hover {
  background: rgba(255, 215, 0, 0.12);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
}

#restart-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: rgba(224, 232, 255, 0.55);
  letter-spacing: 0.5px;
}

/* ── Tips / help overlay ─────────────────────────── */
#tips-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.25s ease;
  padding: 20px;
}

#tips-card {
  position: relative;
  background: rgba(8, 8, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 26px 22px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.22);
  backdrop-filter: blur(16px);
  animation: slide-up 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

#tips-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
  letter-spacing: 0.5px;
  padding-right: 32px; /* leave space for close button */
}

#tips-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #8aa;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}
#tips-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
}

.tip-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #cdd;
}
.tip-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.tip-text strong {
  color: #e8f4ff;
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

/* Speed-pace demo animation */
#speed-demo {
  position: relative;
  height: 80px;
  width: 80px;
  margin: 4px auto 0;
}
.speed-circle-track {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(0, 245, 255, 0.25);
  border-radius: 50%;
  background: rgba(0, 245, 255, 0.04);
}
.speed-finger {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 1.5rem;
  line-height: 1;
  transform-origin: center center;
  animation: speed-circle 3.5s linear infinite;
  filter: drop-shadow(0 0 6px rgba(0, 245, 255, 0.6));
}
@keyframes speed-circle {
  0%   { transform: translate(-50%, -50%) rotate(0deg) translateY(-30px) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg) translateY(-30px) rotate(-360deg); }
}
.speed-caption {
  font-size: 0.75rem;
  color: #8899aa;
  text-align: center;
  letter-spacing: 0.5px;
  margin-top: -4px;
}

#tips-got-it {
  align-self: stretch;
  margin-top: 4px;
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 24px;
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
#tips-got-it:hover {
  background: rgba(0, 245, 255, 0.12);
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.35);
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .speed-finger { animation: none; left: 50%; transform: translate(-50%, -50%); }
}

/* ── Version tag (bottom-right) ──────────────────── */

/* ── About button (bottom-right) ─────────────────── */
#about-btn {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  right: 16px;
  z-index: 150;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--cyan);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
#about-btn:hover {
  background: rgba(0, 245, 255, 0.18);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.45);
}
#about-btn:active { transform: scale(0.94); }

/* ── About overlay ───────────────────────────────── */
#about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.25s ease;
  padding: 20px;
}

#about-card {
  position: relative;
  background: rgba(8, 8, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 26px 22px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.22);
  backdrop-filter: blur(16px);
  animation: slide-up 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

#about-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
  letter-spacing: 0.5px;
  padding-right: 32px;
}

#about-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #8aa;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}
#about-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
}

.about-section {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #cdd;
}
.about-section strong {
  color: #e8f4ff;
  font-weight: 600;
}

.about-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.about-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.2s, box-shadow 0.2s;
}
.about-link:hover {
  background: rgba(0, 245, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.25);
}
.about-link-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

#about-got-it {
  align-self: stretch;
  margin-top: 4px;
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 24px;
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
#about-got-it:hover {
  background: rgba(0, 245, 255, 0.12);
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.35);
}

/* ── Hidden utility ──────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile tweaks ───────────────────────────────── */
@media (max-width: 480px) {
  #hud         { padding-top: max(10px, env(safe-area-inset-top)); padding-right: 12px; padding-bottom: 10px; padding-left: 12px; gap: 8px; }
  #title       { font-size: 1rem; }
  #title-actions { gap: 4px; }
  #bottom-shape-controls { bottom: max(14px, env(safe-area-inset-bottom)); gap: 6px; }
  #shape-selector { padding: 2px 4px; gap: 1px; }
  .shape-btn   { width: 26px; height: 26px; font-size: 0.85rem; }
  #gamemode-btn { min-width: 52px; padding: 0 8px; height: 28px; font-size: 0.72rem; }
  #help-btn    { width: 28px; height: 28px; font-size: 0.85rem; }
  #about-btn   { width: 28px; height: 28px; font-size: 0.85rem; }
  #score-number { font-size: 3.5rem; }
  #score-card  { padding: 20px 18px; gap: 14px; }
  #preview-canvas { width: 220px; height: 220px; }
  .ctrl-btn    { font-size: 0.8rem; padding: 8px 16px; }
  #tips-card   { padding: 22px 18px 18px; gap: 12px; }
  #tips-title  { font-size: 1.05rem; }
  .tip-item    { font-size: 0.82rem; }
  #instructions-panel { bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px)); }
  #btn-controls { bottom: max(66px, calc(env(safe-area-inset-bottom) + 52px)); gap: 8px; }
}
