html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #08090c;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: #fff;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.92);
  text-align: center;
  z-index: 10;
  transition: opacity 0.5s ease;
}

.hidden {
  display: none !important;
}

#splash-title {
  font-size: 54px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 28px;
}

#splash-prompt {
  font-size: 16px;
  font-weight: 500;
  opacity: 0.9;
  /* pulse(0.55 + 0.45*sin(t*2.2)): a slow invitation, not a distraction.
     Period = 2*pi/2.2s ≈ 2.86s. */
  animation: pulse 2.86s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 1; }
}

#splash-hint {
  margin-top: 22px;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.55;
  letter-spacing: 0.2px;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hud-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(10, 11, 14, 0.38);
  border-radius: 10px;
  /* backdrop-filter needs the -webkit- prefix on Safari; harmless no-op
     elsewhere if unsupported (falls back to the flat background above). */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#vitals-panel {
  left: 20px;
  bottom: 24px;
}

#top-panel {
  right: 20px;
  top: 20px;
  align-items: flex-end;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-row-end {
  flex-direction: row-reverse;
}

.hud-icon {
  font-size: 15px;
  opacity: 0.8;
  width: 16px;
  text-align: center;
  flex: none;
}

.bar {
  width: 200px;
  height: 14px;
  background: rgba(38, 38, 38, 0.75);
  border-radius: 7px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: rgb(77, 204, 230);
  border-radius: 7px;
  transition: width 0.08s linear;
}

#breath-pips {
  display: flex;
  gap: 7px;
}

.breath-pip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(51, 51, 51, 0.55);
  transition: background 0.2s ease;
}

.breath-pip.filled {
  background: rgba(153, 217, 255, 0.92);
  box-shadow: 0 0 6px rgba(153, 217, 255, 0.5);
}

#score-pips {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  opacity: 0.92;
}

#day-bar {
  width: 130px;
  position: relative;
}

.day-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.55);
  z-index: 1;
}

#day-bedtime-marker {
  background: rgba(159, 140, 255, 0.75);
}

#day-wake-marker {
  background: rgba(255, 214, 120, 0.75);
}

.bar-thin {
  height: 5px;
  border-radius: 3px;
}

#day-fill {
  background: rgba(217, 191, 128, 0.8);
}

#presence {
  position: absolute;
  left: 24px;
  top: 24px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(20, 18, 22, 0.9);
  opacity: 0.18;
  animation: presence-pulse 3.2s ease-in-out infinite;
}

@keyframes presence-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}

#blocker {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.55);
  z-index: 8;
  cursor: pointer;
}

#blocker-text {
  font-size: 16px;
  opacity: 0.9;
}

/* --- Pause overlay (esc once) --- */
#pause-overlay {
  z-index: 9;
  cursor: pointer;
}

#pause-title {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.9;
  margin-bottom: 18px;
}

#pause-stats {
  font-size: 14px;
  line-height: 1.9;
  opacity: 0.75;
  margin-bottom: 26px;
}

#pause-stats .stat-row span {
  opacity: 0.55;
  margin-right: 8px;
}

#pause-prompt {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.9;
  animation: pulse 2.86s ease-in-out infinite;
}

#pause-hint {
  margin-top: 16px;
  font-size: 12px;
  opacity: 0.45;
  letter-spacing: 0.2px;
}

/* --- End overlay (esc twice): fades to black, session over --- */
#end-overlay {
  z-index: 30;
  background: rgba(4, 4, 6, 0.97);
  opacity: 0;
  transition: opacity 2.2s ease;
}

#end-message {
  font-size: 26px;
  font-weight: 500;
  line-height: 1.5;
  max-width: 520px;
  padding: 0 24px;
  opacity: 0.92;
  margin-bottom: 30px;
}

#end-stats {
  font-size: 14px;
  line-height: 2;
  opacity: 0.6;
  margin-bottom: 40px;
}

#end-prompt {
  font-size: 12px;
  opacity: 0.35;
  letter-spacing: 0.3px;
}

#activity-prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

#activity-prompt-text {
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

#activity-prompt-bar {
  position: static;
  width: 160px;
  height: 6px;
}

#activity-prompt-fill {
  background: rgba(242, 217, 153, 0.95);
  transition: none;
}

#message {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  max-width: 60%;
  text-align: center;
  font-size: 14px;
  font-style: italic;
  opacity: 0.95;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: opacity 0.6s ease;
}

#message.fade-out {
  opacity: 0;
}

#minigame-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(0, 0, 0, 0.45);
}

#minigame-hint {
  font-size: 18px;
  font-weight: 500;
  text-align: center;
}

#minigame-track {
  position: relative;
  width: 320px;
  height: 22px;
  background: rgba(38, 38, 38, 0.85);
  border-radius: 3px;
  overflow: visible;
}

#minigame-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(255, 217, 140, 0.55);
}

#minigame-marker {
  position: absolute;
  top: -6px;
  width: 6px;
  height: 34px;
  margin-left: -3px;
  background: rgba(255, 255, 255, 0.95);
}

#minigame-charge-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: rgba(242, 89, 76, 0.9);
}

#minigame-sweet-zone {
  position: absolute;
  top: 0;
  height: 100%;
  left: 72%;
  width: 22%;
  background: rgba(255, 128, 89, 0.6);
}

#minigame-pips {
  display: flex;
  gap: 8px;
}

#minigame-fade {
  position: fixed;
  inset: 0;
  z-index: 12;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

#boxing-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.boxing-arm {
  display: flex;
  align-items: center;
  gap: 10px;
}

.boxing-joint {
  --flex: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: rgba(216, 179, 242, calc(0.18 + var(--flex) * 0.55));
  box-shadow: 0 0 calc(var(--flex) * 14px) rgba(216, 179, 242, calc(var(--flex) * 0.8));
  transform: scale(calc(1 + var(--flex) * 0.22));
  transition: background 0.08s ease, box-shadow 0.08s ease, transform 0.08s ease;
}

#boxing-bag {
  --impact: 0;
  width: 46px;
  height: 64px;
  border-radius: 18px;
  background: rgba(255, 217, 140, calc(0.35 + var(--impact) * 0.45));
  box-shadow: 0 0 calc(var(--impact) * 18px) rgba(255, 217, 140, calc(var(--impact) * 0.8));
  transform: scale(calc(1 + var(--impact) * 0.16));
  transition: background 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
}

.minigame-pip {
  width: 16px;
  height: 8px;
  border-radius: 2px;
  background: rgba(51, 51, 51, 0.6);
}

.minigame-pip.filled {
  background: rgba(216, 179, 242, 0.9);
}

#ikebana-diagram {
  position: relative;
  width: 280px;
  height: 280px;
  background: rgba(30, 34, 26, 0.55);
  border: 1px solid rgba(200, 230, 180, 0.25);
  border-radius: 6px;
  overflow: hidden;
}

.ikebana-golden-line {
  position: absolute;
  background: rgba(255, 230, 160, 0.35);
}

#ikebana-golden-h {
  left: 0;
  right: 0;
  height: 1px;
}

#ikebana-golden-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.ikebana-pot {
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 30%;
  height: 14%;
  transform: translateX(-50%);
  background: rgba(180, 160, 140, 0.35);
  border: 1px solid rgba(200, 180, 150, 0.4);
}

.ikebana-pot.variant-0 { border-radius: 45% 45% 30% 30%; }
.ikebana-pot.variant-1 { border-radius: 20% 20% 8% 8%; height: 22%; }
.ikebana-pot.variant-2 { border-radius: 50% 50% 15% 15%; height: 8%; width: 42%; }
.ikebana-pot.variant-3 { border-radius: 4px; }

.ikebana-flower {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 180, 210, 0.85);
  box-shadow: 0 0 6px rgba(255, 180, 210, 0.5);
}

.ikebana-flower.size-0 { width: 10px; height: 10px; }
.ikebana-flower.size-1 { width: 16px; height: 16px; }
.ikebana-flower.size-2 { width: 24px; height: 24px; }

.ikebana-flower.hand {
  background: rgba(180, 255, 210, 0.9);
  box-shadow: 0 0 10px rgba(180, 255, 210, 0.75);
  outline: 2px solid rgba(255, 255, 255, 0.8);
}

/* --- Music debug panel (dev tool, toggled with the P key) --- */
#music-debug-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 20;
  pointer-events: auto;
  min-width: 240px;
  font-size: 13px;
}

#music-debug-title {
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
  font-size: 11px;
}

#music-debug-telemetry {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

#music-debug-telemetry span {
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.music-debug-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.music-debug-row span {
  width: 44px;
  opacity: 0.85;
  text-transform: capitalize;
}

.music-debug-row input[type="range"] {
  flex: 1;
  accent-color: rgba(216, 179, 242, 0.9);
}

.music-debug-row input[type="checkbox"] {
  accent-color: rgba(216, 179, 242, 0.9);
  margin: 0;
}

.music-debug-value {
  width: 34px;
  text-align: right;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.voice-mute,
.voice-solo {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 18px;
  text-align: center;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid rgba(216, 179, 242, 0.35);
  background: rgba(216, 179, 242, 0.08);
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
}

.voice-mute:hover,
.voice-solo:hover {
  opacity: 1;
}

.voice-mute.active {
  background: rgba(255, 100, 100, 0.55);
  border-color: rgba(255, 140, 140, 0.8);
  opacity: 1;
}

.voice-solo.active {
  background: rgba(255, 220, 100, 0.55);
  border-color: rgba(255, 230, 140, 0.8);
  opacity: 1;
}

#music-debug-mood-title {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.55;
  font-size: 10px;
  margin: 10px 0 6px;
}

#music-debug-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#music-debug-actions button {
  flex: 1;
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(216, 179, 242, 0.4);
  background: rgba(216, 179, 242, 0.12);
  color: inherit;
  cursor: pointer;
}

#music-debug-actions button:hover {
  background: rgba(216, 179, 242, 0.28);
}

#music-debug-output {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  line-height: 1.4;
  resize: none;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(216, 179, 242, 0.25);
  border-radius: 4px;
  padding: 6px;
  box-sizing: border-box;
}

#music-debug-copied {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.85;
  color: rgba(180, 255, 200, 0.9);
}
