:root {
  --milk: #fdfbf3;
  --cream: #f4efe1;
  --butter: #f5d76e;
  --fridge: #bcd4e6;
  --ink: #2f3a40;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Bricolage Grotesque", sans-serif;
  background: #dfeaf0;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
}

#topbar {
  text-align: center;
  padding: 10px 12px 6px;
  background: linear-gradient(180deg, #ffffff, #f2f7fa);
  border-bottom: 2px solid rgba(160,180,190,0.3);
  z-index: 5;
}
#topbar h1 {
  font-weight: 800;
  font-size: clamp(15px, 3.5vw, 24px);
  letter-spacing: -0.5px;
}
#tagline {
  font-weight: 200;
  font-style: italic;
  font-size: clamp(11px, 2.4vw, 14px);
  color: #6a7b83;
  margin-top: 2px;
}
#stats {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  color: #8a9aa2;
  margin-top: 3px;
}

#canvas {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: none;
}

#controls {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border-top: 2px solid rgba(160,180,190,0.3);
  padding: 8px 10px 10px;
  z-index: 5;
}

.ctl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}
.presets button {
  background: var(--fridge);
  color: var(--ink);
}

.ctl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.ctl-grid label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 800;
  gap: 3px;
}
.ctl-grid label span {
  font-weight: 400;
  font-size: 10px;
  color: #7a8b93;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--fridge), var(--butter));
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--milk);
  border: 3px solid #d8c98f;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--milk);
  border: 3px solid #d8c98f;
  cursor: pointer;
}

button {
  font-family: inherit;
  font-weight: 800;
  font-size: 12px;
  border: none;
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
  transition: transform 0.08s, box-shadow 0.08s;
  user-select: none;
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.08);
}
button.danger {
  background: #f7d0c4;
}
#pourBtn { background: var(--butter); }
#cookieBtn { background: #e8c9a0; }

.fresh-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.fresh-bar {
  flex: 1;
  max-width: 220px;
  height: 10px;
  background: #e5eaed;
  border-radius: 6px;
  overflow: hidden;
}
#freshFill {
  height: 100%;
  width: 100%;
  background: #7fc98a;
  transition: width 0.4s linear, background 0.4s;
}
#freshBtn {
  font-size: 10px;
  padding: 6px 10px;
  background: #cbe6d2;
}

footer {
  text-align: center;
  font-size: 10px;
  color: #7a8b93;
  padding: 5px;
  background: #f2f7fa;
  z-index: 5;
}
footer a { color: #5a8fa8; font-weight: 800; text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .ctl-grid { grid-template-columns: repeat(2, 1fr); }
  button { padding: 8px 10px; font-size: 11px; }
}