/* Brush Buddy — one screen at a time, portrait first, no external assets. */
:root {
  --blue: #3aa6e0;
  --blue-dark: #1b7fb6;
  --ink: #123;
  --paper: #e8f6ff;
  --panel: #ffffff;
  --stop: #9aa7b1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

[hidden] {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
}

button,
.drifter {
  min-width: 64px;
  min-height: 64px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  border-radius: 18px;
  touch-action: manipulation;
}

button svg {
  width: 100%;
  height: 100%;
  display: block;
}

button:focus-visible {
  outline: 3px solid var(--blue-dark);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Home ------------------------------------------------------------------ */
#screen-home {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}

.home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.home-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 64px;
  height: 64px;
  color: var(--blue-dark);
}

.streak {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 24px;
  color: var(--blue-dark);
}

#streak-count {
  min-width: 40px;
  text-align: center;
}

#streak-marks {
  display: flex;
  gap: 3px;
}

.tooth-mark {
  width: 12px;
  height: 16px;
  border-radius: 4px 4px 6px 6px;
  background: #fff;
  border: 2px solid var(--blue);
}

.home-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.start-btn {
  width: min(46vh, 82vw);
  height: min(46vh, 82vw);
  max-width: 280px;
  max-height: 280px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 10px 0 var(--blue-dark);
}

.start-btn svg {
  width: 58%;
  height: 58%;
  margin: auto;
}

.stars-total {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 26px;
  font-weight: 700;
  color: var(--blue-dark);
}

.stars-total svg {
  width: 34px;
  height: 34px;
}

.note {
  width: 40px;
  height: 40px;
  color: #d97706;
}

.sticker-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0 24px;
  min-height: 72px;
}

.sticker {
  width: 56px;
  height: 56px;
  padding: 4px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(18, 51, 68, 0.12);
}

.sticker svg {
  width: 100%;
  height: 100%;
}

#sticker-more {
  font-weight: 700;
  color: var(--blue-dark);
}

/* Settings overlay ------------------------------------------------------ */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(232, 246, 255, 0.98);
  overflow-y: auto;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-head h2 {
  margin: 0;
  font-size: 24px;
  color: var(--blue-dark);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.btn-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid #cfe9f8;
  font-size: 18px;
  text-align: start;
}

.btn-lang svg {
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--blue-dark);
}

.btn-lang[aria-pressed="true"],
.len-btn[aria-pressed="true"] {
  border-color: var(--blue);
  background: #d8f0ff;
}

.length-row {
  display: flex;
  gap: 12px;
}

.len-btn {
  width: 96px;
  height: 96px;
  color: var(--blue-dark);
  background: #fff;
  border: 2px solid #cfe9f8;
}

/* Session --------------------------------------------------------------- */
#screen-session {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#screen-session > * {
  position: absolute;
}

#mouth-map {
  border-radius: 24px;
  overflow: visible;
}

#mouth-map .mouth-outline {
  fill: none;
  stroke: #7fc4e8;
  stroke-width: 2;
}

#mouth-map .zone {
  fill: #d5efff;
  stroke: #7fc4e8;
  stroke-width: 2;
  transition: fill 0.25s;
}

#mouth-map .zone.active {
  fill: #6ec8f5;
  animation: pulse 1.2s ease-in-out infinite;
}

#ring {
  pointer-events: none;
}

#ring circle {
  fill: none;
  stroke: var(--blue-dark);
  stroke-width: 6;
  stroke-dasharray: 301.59;
  stroke-dashoffset: inherit;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  opacity: 0.55;
}

#buddy {
  color: var(--blue-dark);
  border-radius: 50%;
  transition: transform 0.6s, left 0.6s, top 0.6s;
}

#buddy.giggle {
  animation: giggle 0.45s ease-in-out;
}

#numeral {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  line-height: 1;
  color: var(--blue-dark);
  font-variant-numeric: tabular-nums;
}

#session-stars,
#done-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.star {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #cfe9f8;
  border: 2px solid #9fd6f2;
}

.star.earned {
  background: #ffd24a;
  border-color: #e0a800;
}

#btn-stop {
  color: var(--stop);
  background: rgba(154, 167, 177, 0.12);
  border-radius: 14px;
}

#btn-mute-session {
  color: var(--blue-dark);
}

#drifter-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.drifter {
  position: absolute;
  width: 72px;
  height: 72px;
  pointer-events: auto;
  animation: drift var(--drift-ms, 9000ms) linear forwards;
}

.drifter svg {
  width: 100%;
  height: 100%;
}

.drifter.pop {
  animation: pop 0.25s ease-out forwards !important;
}

/* Done ------------------------------------------------------------------ */
#screen-done {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.done-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  z-index: 2;
}

#done-stars .star {
  width: 56px;
  height: 56px;
}

#btn-home {
  width: 110px;
  height: 110px;
  color: #fff;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 8px 0 var(--blue-dark);
}

#celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#celebration .confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: confetti 2.8s linear infinite;
}

/* Motion ---------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% { fill-opacity: 1; }
  50% { fill-opacity: 0.65; }
}

@keyframes giggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

@keyframes drift {
  from { transform: translate(0, 0); opacity: 0.9; }
  to { transform: translate(var(--drift-x, 0), -70vh); opacity: 0; }
}

@keyframes pop {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.6); opacity: 0; }
}

@keyframes confetti {
  0% { transform: translateY(-5vh) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  .zone.active,
  .drifter,
  #celebration * {
    animation: none !important;
  }

  #buddy {
    transition: none !important;
  }
}
