@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;600&family=Share+Tech+Mono&display=swap');

:root {
  --core-cyan: #00f3ff;
  --core-pink: #ff00ea;
  --core-gold: #ffbe0b;
  --bg-glass: rgba(5, 8, 14, 0.65);
  --bg-darker: rgba(2, 4, 8, 0.95);
  --border-accent: rgba(0, 243, 255, 0.3);
  --text-glow: 0 0 8px rgba(0, 243, 255, 0.6);
  --panel-border: 1px solid var(--border-accent);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
  background: #000;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
}

#canvas-container {
  position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1;
}

#canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

/* ───── HUD OVERLAYS ───── */
#hud-wrapper {
  position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 10; pointer-events: none;
}

.hud-panel {
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--panel-border);
  clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
  display: flex; flex-direction: column;
  box-shadow: 0 0 20px rgba(0,243,255,0.05);
  transition: transform 0.4s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.4s;
}

#hud-left { 
  position: absolute; top: 20px; left: 20px; 
  width: 340px; max-height: calc(100vh - 40px);
}

#hud-right { 
  position: absolute; bottom: 20px; right: 20px; 
  width: 260px; height: auto;
}

/* HUD HIDING LOGIC + CLICK THROUGH FIX */
.hud-hidden #hud-left { transform: translateX(-120%); opacity: 0; pointer-events: none; }
.hud-hidden #hud-right { transform: translateX(120%); opacity: 0; pointer-events: none; }
.hud-hidden .hud-panel { pointer-events: none; }

.hud-header {
  padding: 15px 20px; border-bottom: var(--panel-border);
  background: linear-gradient(90deg, rgba(0,243,255,0.1), transparent);
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-shrink: 0;
}
.hud-title { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 1.4rem; color: var(--core-cyan); text-shadow: var(--text-glow); letter-spacing: 2px; }
.hud-version { font-family: 'Share Tech Mono', monospace; font-size: 0.75rem; color: #88a; }

.hud-content {
  padding: 20px; overflow-y: auto; scrollbar-width: none;
  flex: 1; display: flex; flex-direction: column; gap: 20px;
}
.hud-content::-webkit-scrollbar { display: none; }

.section-group { display: flex; flex-direction: column; gap: 10px; }
.section-label {
  font-family: 'Orbitron', sans-serif; font-size: 0.7rem; color: #7ab;
  text-transform: uppercase; letter-spacing: 2px;
  display: flex; align-items: center; gap: 8px;
}
.section-label::before { content: ''; width: 8px; height: 8px; background: var(--core-cyan); display: inline-block; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.section-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-accent), transparent); }

/* CONTROLS */
select, button, input[type="range"] { font-family: 'Share Tech Mono', monospace; }

.cyber-select {
  width: 100%; background: var(--bg-darker); color: var(--core-cyan);
  border: 1px solid rgba(0,243,255,0.2); padding: 8px 12px;
  font-size: 0.85rem; cursor: pointer; outline: none; appearance: none;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: all 0.2s;
}
.cyber-select option { background: #020408; color: var(--core-cyan); }
.cyber-select:hover { background: rgba(0,243,255,0.05); border-color: var(--core-cyan); box-shadow: inset 0 0 10px rgba(0,243,255,0.2); }

.cyber-btn {
  width: 100%; background: rgba(0,243,255,0.05); color: var(--core-cyan);
  border: 1px solid var(--border-accent); padding: 10px;
  font-weight: bold; font-size: 0.8rem; cursor: pointer; text-transform: uppercase; letter-spacing: 1px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: all 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.cyber-btn:hover { background: rgba(0,243,255,0.15); border-color: var(--core-cyan); box-shadow: 0 0 15px rgba(0,243,255,0.3); text-shadow: var(--text-glow); }
.cyber-btn:active { transform: scale(0.98); }

.btn-record { color: #ff0055; border-color: rgba(255,0,85,0.6); box-shadow: inset 0 0 10px rgba(255,0,85,0.1); }
.btn-record:hover { background: rgba(255,0,85,0.1); border-color: #ff0055; box-shadow: 0 0 15px rgba(255,0,85,0.3); text-shadow: 0 0 8px #ff0055; }
.btn-record.recording { background: #ff0055; color: #fff; box-shadow: 0 0 20px rgba(255,0,85,0.5); animation: pulseRecord 1s infinite alternate; border-color: #ff0055;}

@keyframes pulseRecord { from { box-shadow: 0 0 10px rgba(255,0,85,0.5); } to { box-shadow: 0 0 30px rgba(255,0,85,0.9); } }

.hint-txt { font-size: 0.7rem; color: #689; font-family: 'Share Tech Mono'; margin-top: 6px; }

/* SHAPES GRID */
.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shape-cell {
  background: var(--bg-darker); border: 1px solid rgba(0,243,255,0.1);
  color: #689; font-size: 0.65rem; text-align: center; padding: 10px 4px;
  cursor: pointer; transition: all 0.2s;
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}
.shape-cell:hover { border-color: var(--core-cyan); color: var(--core-cyan); }
.shape-cell.active {
  background: rgba(0,243,255,0.15); border-color: var(--core-cyan);
  color: #fff; box-shadow: inset 0 0 10px rgba(0,243,255,0.4); text-shadow: 0 0 5px var(--core-cyan);
}

/* SLIDERS */
.slider-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.slider-label { min-width: 70px; font-size: 0.75rem; color: #8ab; }
.slider-val { min-width: 30px; font-size: 0.75rem; color: var(--core-cyan); text-align: right; }
input[type="range"] {
  flex: 1; height: 2px; -webkit-appearance: none; appearance: none; background: rgba(0,243,255,0.2); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px; background: var(--core-cyan);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: 0 0 10px var(--core-cyan);
}

/* RIGHT HUD STATS */
.stat-box { background: var(--bg-darker); border-left: 2px solid var(--core-cyan); padding: 10px 15px; margin-bottom: 10px; }
.stat-val { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: #fff; text-shadow: var(--text-glow); display: flex; align-items: baseline; gap: 5px;}
.stat-val small { font-size: 0.7rem; color: var(--core-cyan); }
.stat-desc { font-size: 0.65rem; color: #7ab; text-transform: uppercase; letter-spacing: 2px;}

/* COLORS */
#color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.col-btn { height: 24px; cursor: pointer; border: 1px solid rgba(255,255,255,0.1); clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px); transition: transform 0.2s; }
.col-btn:hover { transform: scale(1.05); border-color: #fff; }

/* CUSTOM COLOR PICKER */
.color-picker-wrap {
  display: flex; align-items: center; gap: 10px; margin-top: 6px;
  background: rgba(0,243,255,0.05); border: 1px solid rgba(0,243,255,0.2);
  padding: 6px 12px; clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
input[type="color"] {
  background: transparent; border: none; outline: none; cursor: pointer; width: 100%; height: 22px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--core-cyan); }

/* TRANSPORT CONTROLS */
.transport-group { background: var(--bg-darker); padding: 15px; border: 1px solid rgba(0,243,255,0.1); display: flex; flex-direction: column; gap: 15px; }
.transport-buttons { display: flex; justify-content: center; align-items: center; gap: 20px; }
.btn-icon { background: none; border: none; color: var(--core-cyan); cursor: pointer; display: flex; align-items: center; transition: all 0.2s;}
.btn-icon:hover { color: #fff; filter: drop-shadow(0 0 5px var(--core-cyan)); }
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; }
.play-large svg { width: 32px; height: 32px; }
.track-time { font-family: 'Share Tech Mono'; font-size: 0.75rem; color: #fff; text-align: center; margin-bottom: -5px; }
.progress-wrap { width: 100%; height: 6px; background: rgba(0,243,255,0.1); cursor: pointer; position: relative; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--core-cyan); width: 0%; box-shadow: 0 0 10px var(--core-cyan); transition: width 0.05s linear; }

/* OVERLAY TOGGLE */
#toggle-hud {
  position: absolute; top: 20px; right: 20px; z-index: 20;
  width: 40px; height: 40px; background: rgba(0,243,255,0.1); border: 1px solid var(--core-cyan);
  color: var(--core-cyan); cursor: pointer; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  display: flex; justify-content: center; align-items: center; transition: all 0.3s;
}
#toggle-hud:hover { background: rgba(0,243,255,0.3); box-shadow: 0 0 15px var(--core-cyan); color: #fff; }
#toggle-hud svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }

/* HIDE DEFAULT FILE INPUT */
input[type="file"] { 
  position: absolute; 
  opacity: 0; 
  overflow: hidden; 
  pointer-events: none;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
  body { overflow-y: auto; overflow-x: hidden; }
  
  #canvas-container { position: fixed; }
  
  #hud-wrapper { 
    position: absolute;
    height: auto;
    flex-direction: column; 
    padding: 70px 10px 20px 10px; 
    overflow: visible; 
    justify-content: flex-start;
    transition: opacity 0.3s;
  }
  
  #hud-left, #hud-right { 
    position: relative; 
    top: 0; left: 0; right: 0; bottom: 0; 
    width: 100%; 
    max-height: none; 
    margin-bottom: 20px;
    transform: none !important;
  }

  /* ENSURE CLICK-THROUGH ON MOBILE HIDDEN STATE */
  #hud-wrapper.hud-hidden { opacity: 0; pointer-events: none; }

  #toggle-hud { position: absolute; top: 15px; right: 15px; z-index: 100; }
}

/* ───── RECORDING PREVIEW OVERRIDE ───── */
body.recording-active #canvas-container canvas {
  object-fit: contain !important;
  box-shadow: 0 0 0 1px var(--core-cyan); 
}