@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* Root Variables */
:root {
  /* Base Colors */
  --bg: #F6F7FB;
  --text: #262625;
  --white: #FFF;
  --panel: #FFF;
  --panel-border: #EEF4F7;
  --border: #CCCDD0;
  --bar-bg: #F6F7FB;

  /* Phases */
  --prep: #DA6E00;
  --work: #BA2721;
  --rest: #61993B;
  --active: #C5BED4;

  /* Slider */
  --slider-fill: #C5BED4;
  --slider-track: #C5BED4;
  --slider-thumb: #8172A0;
  --slider-thumb-hover: #746395;

  /* Buttons / Toggles */
  --toggle: #8e81aa;

  /* Layout */
  --row-gap: 6px;
  --max-width: 520px;
  --radius: 12px;
  --transition: 0.2s ease;
  --shadow: rgba(0, 0, 0, 0.1);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Roboto, "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
  overflow-y: auto; /* ✅ allow scrolling on all devices */
  -webkit-overflow-scrolling: touch;
}

/* Container (Desktop) */
.container {
  background-color: var(--white);
  padding: 10px;
  border-radius: var(--radius);
  box-shadow: 0 4px 10px var(--shadow);
  width: 100%;
  max-width: var(--max-width);
  text-align: center;
  margin: auto;
}

/* Main Layout */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

/* Typography */
.round-indicator {
  font-weight: 800;
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.phase-label {
  font-weight: 800;
  font-size: 1.25rem;
  margin-bottom: 1px;
}

.digits {
  font-size: 7.00rem;
  font-weight: 900;
  margin: 1px 0;
}

.status {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

/* Screen & Bar */
.screen {
  width: 100%;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  margin-bottom: 12px;
  background: var(--panel);
  transition: background 0.25s;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.bar-container {
  width: 100%;
  height: 16px;
  background: var(--bar-bg);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 6px;
}

.bar-fill {
  width: 0%;
  height: 100%;
  transition: width 0.12s linear;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
  width: 100%;
}

.controls .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.controls .row:first-child { margin-top: var(--row-gap); }
.controls .row:last-child { margin-bottom: var(--row-gap); }

/* Toggle Buttons */
.toggle {
  flex: 1 1 auto;
  min-width: 84px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toggle.active {
  background: var(--active);
  border-color: var(--active);
  color: #fff;
}

.controls .row:last-child button {
  flex: 1 1 100%;
}

/* Range Sliders */
input[type='range'] {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--slider-fill) 0%,
    var(--slider-fill) var(--value, 0%),
    var(--slider-track) var(--value, 0%),
    var(--slider-track) 100%
  );
  cursor: pointer;
  transition: background var(--transition);
  outline: none;
}

/* Thumbs */
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--slider-thumb);
  border: 2px solid var(--slider-thumb-hover);
  transition: transform 0.15s ease, background 0.15s ease;
  margin-top: -6px;
}

input[type='range']::-webkit-slider-thumb:hover {
  background: var(--slider-thumb-hover);
  transform: scale(1.08);
}

input[type='range']:active::-webkit-slider-thumb {
  transform: scale(0.95);
}

/* Firefox */
input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--slider-thumb);
  border: 2px solid var(--slider-thumb-hover);
  transition: transform 0.15s ease, background 0.15s ease;
}

input[type='range']::-moz-range-thumb:hover {
  background: var(--slider-thumb-hover);
  transform: scale(1.08);
}

input[type='range']:active::-moz-range-thumb {
  transform: scale(0.95);
}

/* Range Row (Improved) */
.range-row {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  box-sizing: border-box;
}

.range-row label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Slider inside range row */
.range-row input[type='range'] {
  width: 100%;
  height: 10px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--slider-fill) 0%,
    var(--slider-fill) var(--value, 0%),
    var(--slider-track) var(--value, 0%),
    var(--slider-track) 100%
  );
  transition: background var(--transition);
  outline: none;
  cursor: pointer;
}

/* Round Settings */
.round-settings {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.round-row {
  padding: 10px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}

.slider-row {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.slider-row + .slider-row {
  margin-top: 1px;
}

.slider-row input[type='range'] {
  flex: 1;
}

.stepper {
  display: flex;
  gap: 4px;
  align-items: center;
}

.stepper button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--toggle);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.stepper input {
  width: 50px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
}

/* Footer */
.footer {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: auto;
  margin-bottom: 12px;
}

.small-hint {
  font-size: 0.8rem;
  color: #666;
  margin-top: 6px;
}

/* Responsive Adjustments */

/* Mobile: Portrait */
@media (max-width: 520px) {
  body {
    padding: 8px;
  }
  .digits {
    font-size: 3.4rem;
  }
  .container {
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
    width: 100%;
  }
}

/* Mobile: Landscape (scrollable layout) */
@media (max-height: 520px) and (orientation: landscape) {
  body {
    padding: 8px;
    overflow-y: auto; /* ✅ scrolling enabled */
  }

  .container {
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
  }

  .screen {
    min-height: 60vh; /* ✅ fills most of viewport but keeps controls visible */
  }

  main {
    padding: 12px;
  }
}
