* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --ui-font: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --green:  #2eb872;
  --orange: #f59e0b;
  --red:    #e5484d;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--ui-font);
  touch-action: manipulation;
  user-select: none;
}

body {
  background: radial-gradient(ellipse at 50% 0%, #2c4a7c 0%, #1a2e52 45%, #101c36 100%);
  color: #fff;
}

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}

/* ---------- Barre du haut ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
}
#logo { font-size: clamp(1.1rem, 2.4vw, 1.6rem); font-weight: 800; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
#toolbar { display: flex; gap: 8px; }
.tool {
  font: inherit; font-size: 1.25rem; line-height: 1;
  width: 46px; height: 46px; border: none; border-radius: 12px;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
.tool:hover { background: rgba(255,255,255,.22); }
.tool:active { transform: scale(.94); }
.tool.off { opacity: .35; }

/* ---------- Scène centrale ---------- */
#stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 0 12px;
}

#dial {
  height: min(66vh, 92vw);
  width: auto;
  max-width: 100%;
  filter: drop-shadow(0 24px 50px rgba(0,0,0,.5));
  cursor: grab;
  touch-action: none;   /* sinon le mobile transforme le glissement en défilement */
}
#dial.dragging { cursor: grabbing; }

#dial .wedge { transition: fill .4s; }
#dial text {
  font-family: var(--ui-font);
  font-weight: 800;
  fill: #24314e;
}

#readout { display: flex; align-items: center; gap: 14px; }
#digits {
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  padding: 2px 26px;
  border-radius: 99px;
  background: rgba(255,255,255,.1);
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  min-width: 5.2ch; text-align: center;
}
#digits.hiddenDigits { visibility: hidden; }
.adjust {
  font: inherit; font-size: 1.2rem; font-weight: 800;
  width: 54px; height: 54px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
.adjust:hover { background: rgba(255,255,255,.24); }
.adjust:active { transform: scale(.92); }

#hint {
  color: rgba(255,255,255,.55);
  font-size: clamp(.8rem, 1.6vw, 1rem);
  font-weight: 600;
}

/* ---------- Barre du bas ---------- */
#bottombar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 14px;
  padding: 12px 16px 20px;
}
#presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.preset {
  font: inherit; font-weight: 800; font-size: clamp(.85rem, 1.7vw, 1.05rem);
  padding: 10px 16px; border: none; border-radius: 99px;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
.preset:hover { background: rgba(255,255,255,.24); }
.preset:active { transform: scale(.95); }

#controls { display: flex; gap: 10px; }
#btnStart {
  font: inherit; font-weight: 800; font-size: clamp(1rem, 2.2vw, 1.35rem);
  padding: 14px 34px; border: none; border-radius: 99px;
  background: linear-gradient(180deg, #34d17f, #1f9d5c);
  color: #fff; cursor: pointer;
  box-shadow: 0 8px 22px rgba(46,184,114,.4);
  transition: transform .1s, filter .15s;
}
#btnStart:hover { filter: brightness(1.08); }
#btnStart:active { transform: scale(.96); }
#btnStart.pause {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  box-shadow: 0 8px 22px rgba(245,158,11,.4);
}
#btnReset {
  font: inherit; font-size: 1.4rem; font-weight: 800;
  width: 56px; border: none; border-radius: 99px;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
#btnReset:hover { background: rgba(255,255,255,.24); }
#btnReset:active { transform: scale(.94); }

/* ---------- Plein écran : rien que le minuteur ---------- */
body.zen #topbar,
body.zen #bottombar,
body.zen #hint,
body.zen #readout { display: none; }
body.zen #dial { height: min(92vh, 96vw); }

#btnExitZen {
  display: none;
  position: fixed; top: 14px; right: 14px; z-index: 30;
  font: inherit; font-size: 1.3rem; font-weight: 800; line-height: 1;
  width: 52px; height: 52px; border: none; border-radius: 14px;
  background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
#btnExitZen:hover { background: rgba(255,255,255,.28); }
#btnExitZen:active { transform: scale(.94); }
body.zen #btnExitZen { display: block; }

/* ---------- Panneau des plages de couleur ---------- */
#zonesOverlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 14, 30, .6);
  backdrop-filter: blur(3px);
}
#zonesOverlay.hidden { display: none; }
#zonesPanel {
  width: min(480px, 92vw);
  max-height: 86vh; overflow-y: auto;
  background: #182647;
  border-radius: 20px;
  padding: 22px 24px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.panelHeader { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panelHeader h2 { font-size: 1.25rem; }
.bigClose {
  font: inherit; font-size: 1.1rem; font-weight: 800;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.bigClose:hover { background: rgba(255,255,255,.24); }
.zoneHint { color: rgba(255,255,255,.65); font-size: .88rem; line-height: 1.5; margin-bottom: 14px; }

#zoneList { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#zoneList li {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07);
  border-radius: 12px; padding: 8px 12px;
}
#zoneList input[type="color"] {
  width: 52px; height: 40px; padding: 0; border: none; border-radius: 10px;
  background: none; cursor: pointer;
}
#zoneList input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
#zoneList input[type="color"]::-webkit-color-swatch { border: none; border-radius: 8px; }
#zoneList .zoneLabel { font-weight: 700; font-size: .95rem; }
#zoneList .zoneRange { color: rgba(255,255,255,.5); font-size: .82rem; margin-left: auto; }
#zoneList input[type="number"] {
  font: inherit; font-weight: 800; text-align: center;
  width: 72px; padding: 8px 4px; border: none; border-radius: 9px;
  background: rgba(255,255,255,.14); color: #fff;
}
.zoneDel {
  font: inherit; font-size: 1rem;
  width: 38px; height: 38px; border: none; border-radius: 9px;
  background: rgba(255,255,255,.1); color: #fff; cursor: pointer;
}
.zoneDel:hover { background: rgba(229,72,77,.5); }

.zoneActions { display: flex; gap: 10px; flex-wrap: wrap; }
.zoneActions button {
  font: inherit; font-weight: 800; font-size: .95rem;
  padding: 11px 18px; border: none; border-radius: 99px;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  transition: background .15s, transform .1s;
}
.zoneActions button:hover { background: rgba(255,255,255,.24); }
.zoneActions button:active { transform: scale(.96); }
#btnAddZone { background: linear-gradient(180deg, #34d17f, #1f9d5c); }

/* ---------- Fin du temps ---------- */
#alarmOverlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(229,72,77,.35);
  backdrop-filter: blur(3px);
  animation: alarmPulse .8s ease-in-out infinite;
}
#alarmOverlay.hidden { display: none; }
@keyframes alarmPulse {
  0%, 100% { background: rgba(229,72,77,.30); }
  50%      { background: rgba(229,72,77,.55); }
}
#alarmBox {
  text-align: center;
  background: #182647;
  padding: 40px 56px;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
#alarmEmoji { font-size: clamp(4rem, 12vw, 7rem); animation: ring .5s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { transform: rotate(-12deg); }
  50%      { transform: rotate(12deg); }
}
#alarmText { font-size: clamp(1.6rem, 5vw, 3rem); font-weight: 800; margin: 10px 0 24px; }
#btnDismiss {
  font: inherit; font-weight: 800; font-size: clamp(1rem, 2.4vw, 1.3rem);
  padding: 14px 30px; border: none; border-radius: 99px;
  background: linear-gradient(180deg, #34d17f, #1f9d5c); color: #fff; cursor: pointer;
  transition: transform .1s;
}
#btnDismiss:active { transform: scale(.96); }
