/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #06060e;
  color: #c8c8d4;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== Start Overlay ===== */
#start-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  background: rgba(6,6,14,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#start-overlay.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }

.start-content { text-align: center; max-width: 440px; padding: 2rem; }
.start-title {
  font-size: 2.6rem; font-weight: 300; letter-spacing: 0.25em;
  text-transform: uppercase; margin-bottom: 0.6rem;
  background: linear-gradient(135deg, #b8a0d8, #80c8e0, #d0a0c0);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.start-subtitle { font-size: 0.92rem; font-weight: 300; color: #7a7a90; margin-bottom: 2.5rem; letter-spacing: 0.08em; }
.start-hint { font-size: 0.62rem; color: #3a3a50; margin-top: 2.8rem; letter-spacing: 0.2em; line-height: 1.6; text-transform: uppercase; font-weight: 500; }

.btn-glow {
  padding: 14px 52px; font-family: inherit; font-size: 1rem; font-weight: 500;
  letter-spacing: 0.15em; text-transform: uppercase; color: #e0d8f0;
  background: rgba(120,90,180,0.15); border: 1px solid rgba(160,130,220,0.3);
  border-radius: 50px; cursor: pointer; transition: all 0.4s ease; outline: none;
}
.btn-glow:hover {
  background: rgba(120,90,180,0.3); border-color: rgba(160,130,220,0.6);
  box-shadow: 0 0 30px rgba(120,90,180,0.3), 0 0 60px rgba(120,90,180,0.1);
  transform: translateY(-1px);
}
.btn-glow:active { transform: translateY(0); }

/* ===== App Wrapper ===== */
#app-wrapper {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; padding: 12px 16px 24px;
}

/* ===== Top Bar ===== */
#top-bar {
  width: 100%; max-width: 800px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; margin-bottom: 8px;
}
.logo { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.2em; color: #50506a; text-transform: uppercase; }
.byline { font-size: 0.55rem; font-weight: 500; letter-spacing: 0.2em; color: #50506a; text-transform: uppercase; text-align: center; width: 100%; margin-top: 0.6em; padding-bottom: 0.3em; }
.toolbar-actions { display: flex; align-items: center; gap: 4px; }
.separator { width: 1px; height: 18px; background: rgba(120,120,160,0.2); margin: 0 6px; }

.btn-icon {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; font-family: inherit; font-size: 0.68rem; font-weight: 400;
  letter-spacing: 0.04em; color: #8888a0;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px; cursor: pointer; transition: all 0.25s ease; outline: none;
}
.btn-icon:hover { color: #c0c0d8; background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); }
.btn-icon.active { color: #b898e0; background: rgba(140,100,200,0.12); border-color: rgba(140,100,200,0.25); }
.btn-icon svg { flex-shrink: 0; }

.record-dot { width: 7px; height: 7px; border-radius: 50%; background: #e04060; display: inline-block; }
.btn-record.recording .record-dot { animation: pulse-dot 1s ease-in-out infinite; }
.btn-record.recording { color: #e04060; border-color: rgba(224,64,96,0.3); }
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

/* ===== Canvas Container ===== */
#canvas-container {
  position: relative;
  width: 100%; max-width: 800px;
  aspect-ratio: 1 / 1;
  border-radius: 8px; overflow: hidden;
  background: #06060e;
  border: 1px solid rgba(255,255,255,0.06);
}
#terrain-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; display: block;
}

/* ===== Frozen / Recording overlays inside canvas ===== */
#frozen-indicator {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: rgba(80,180,220,0.12);
  border: 1px solid rgba(80,180,220,0.2); border-radius: 6px;
  font-size: 0.68rem; color: #60b8d8; z-index: 5;
}
.btn-tiny {
  padding: 2px 8px; font-family: inherit; font-size: 0.6rem; color: #60b8d8;
  background: rgba(80,180,220,0.1); border: 1px solid rgba(80,180,220,0.2);
  border-radius: 3px; cursor: pointer; outline: none; transition: all 0.2s ease;
}
.btn-tiny:hover { background: rgba(80,180,220,0.2); }

#recording-indicator {
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: rgba(224,64,96,0.12);
  border: 1px solid rgba(224,64,96,0.25); border-radius: 6px;
  font-size: 0.7rem; color: #e04060; z-index: 5;
}
.rec-pulse { width: 7px; height: 7px; border-radius: 50%; background: #e04060; animation: pulse-dot 1s ease-in-out infinite; }
.rec-text { font-weight: 600; letter-spacing: 0.1em; }
.rec-time { font-variant-numeric: tabular-nums; color: #c03050; }

/* ===== Control Panel (below canvas) ===== */
#control-panel {
  width: 100%; max-width: 800px; margin-top: 10px;
}
.panel-content {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  padding: 14px 18px;
  background: rgba(12,12,22,0.7);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
}
.control-group {
  flex: 1 1 110px; min-width: 100px;
  display: flex; flex-direction: column; gap: 4px;
}
.control-group label {
  display: flex; align-items: center; justify-content: space-between;
}
.control-label { font-size: 0.62rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: #70708a; }
.control-value { font-size: 0.58rem; color: #50506a; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 32px; background: transparent; cursor: pointer; outline: none;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%; height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #8070b0; border: 2px solid #a890d0;
  box-shadow: 0 0 6px rgba(136,112,176,0.4); margin-top: -9px;
}
input[type="range"]::-moz-range-track {
  width: 100%; height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #8070b0; border: 2px solid #a890d0;
  box-shadow: 0 0 6px rgba(136,112,176,0.4);
}

/* ===== Tooltip ===== */
#tooltip {
  position: fixed; padding: 4px 9px; font-size: 0.64rem; color: #a0a0b8;
  background: rgba(20,20,35,0.88); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px; z-index: 200; pointer-events: none;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .start-title { font-size: 1.7rem; letter-spacing: 0.12em; }
  /* Hide text labels on toolbar buttons EXCEPT Drift Again */
  .btn-icon:not(#btn-randomize) span:not(.record-dot) { display: none; }
  .control-group { flex: 1 1 80px; min-width: 70px; }
}
@media (max-width: 360px) {
  /* Only at very narrow widths, collapse Drift Again to icon too */
  #btn-randomize span { display: none; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,120,160,0.15); border-radius: 3px; }
