
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --light-color: #ff0000;
  --light-intensity: 5%;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #000;
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior: none;
}

body {
  position: relative;
  color: #fff;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

.light-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #000;
  overflow: hidden;
  touch-action: manipulation;
}

.light-screen.lit {
  background: color-mix(
    in srgb,
    var(--light-color) var(--light-intensity),
    #000
  );
}

.countdown {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 16px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

.controls {
  position: fixed;
  z-index: 5;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 9px;
  border: 1px solid #393939;
  border-radius: 20px;
  background: rgba(118, 4, 4, 0.374);
  box-shadow: 0 5px 25px rgba(244, 4, 4, 0.833);
}

.control-btn {
  min-width: 0;
  min-height: 58px;
  padding: 6px 2px;
  border: 1px solid #f10909bf;
  border-radius: 12px;
  background: #480101e3;
  color: #ef0808a2;
  font-size: clamp(10px, 3vw, 13px);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.control-btn:active,
.confirm-btn:active,
.cancel-btn:active {
  transform: scale(0.97);
}

.timer-panel {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(290px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid #d11010;
  border-radius: 20px;
  background: #4f0202d7;
  color: #f60909;
  box-shadow: 0 10px 50px rgba(247, 5, 5, 0.916);
  overscroll-behavior: contain;
}

.timer-panel h2 {
  margin: 0 0 16px;
  text-align: center;
  font-size: 20px;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timer-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 40px;
  padding: 8px 6px;
  border: 1px solid #f70808;
  border-radius: 9px;
  background: #6c0303e9;
  font-size: 13px;
  cursor: pointer;
}

.timer-options input {
  flex-shrink: 0;
  margin: 0;
  accent-color: #ff3030;
}

.confirm-btn,
.cancel-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  color: #f60808;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

.confirm-btn {
  background: #b51e2a;
}

.cancel-btn {
  margin-top: 7px;
  background: #383838;
}

/* Petits téléphones */
@media (max-width: 350px) {
  .controls {
    left: 5px;
    right: 5px;
    gap: 4px;
    padding: 6px;
  }

  .control-btn {
    min-height: 54px;
    font-size: 10px;
    border-radius: 10px;
  }

  .timer-panel {
    padding: 15px;
  }
}

/* Prévisualisation mobile sur grand écran */
@media (min-width: 600px) {
  body {
    width: min(100%, 430px);
    height: 100dvh;
    margin: 0 auto;
    border-left: 1px solid #212020;
    border-right: 1px solid #242424;
  }

  .light-screen {
    left: 50%;
    right: auto;
    width: min(100%, 430px);
    transform: translateX(-50%);
  }

  .controls {
    left: max(calc((100vw - 410px) / 2), calc((100vw - 430px) / 2 + 10px));
    right: auto;
    width: min(calc(100vw - 20px), 410px);
  }
}