/* style.css */

/* ----- Base / Reset ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f14;
  --card: rgba(255, 255, 255, 0.06);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.64);
  --muted-2: rgba(255, 255, 255, 0.45);
  --border: rgba(255, 255, 255, 0.12);

  --btn: rgba(255, 255, 255, 0.10);
  --btn-hover: rgba(255, 255, 255, 0.14);
  --btn-active: rgba(255, 255, 255, 0.18);

  --primary: rgba(80, 200, 160, 0.85);
  --danger: rgba(255, 90, 90, 0.85);
  --info: rgba(0, 170, 255, 0.85);

  --radius: 18px;
  --pad: 14px;
  --gap: 12px;

  /* App width (no whole-app scaling; true responsive layout) */
  --app-max: 720px;

  /* ===== Timer digit sizing (RESPONSIVE) ===== */
  --digit-w: clamp(58px, 12vw, 118px);
  --digit-h: clamp(64px, 12vw, 104px);
  --digit-size: clamp(54px, 10vw, 92px);
  --digit-gap: clamp(4px, 1.2vw, 8px);

  --dot-w: clamp(16px, 3vw, 22px);
  --dot-size: clamp(44px, 8vw, 80px);
}

/* ----- Page ----- */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 800px at 50% 10%, rgba(255, 255, 255, 0.07), transparent 60%),
    radial-gradient(900px 600px at 10% 90%, rgba(80, 200, 160, 0.10), transparent 55%),
    radial-gradient(900px 600px at 90% 90%, rgba(255, 90, 90, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);

  font-family: "Orbitron", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";

  line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* Prevent accidental horizontal scroll on mobile */
  overflow-x: hidden;
}

/* ----- Viewport (centered, safe-area aware) ----- */
.viewport {
  /* Use stable viewport height to prevent iOS Safari "breathing" on scroll */
  min-height: 100vh;
  display: grid;
  place-items: center;

  padding:
    calc(env(safe-area-inset-top) + var(--pad))
    var(--pad)
    calc(env(safe-area-inset-bottom) + var(--pad))
    var(--pad);
}

/* iOS/modern browsers: stable viewport that won't resize when the address bar shows/hides */
@supports (height: 100svh) {
  .viewport {
    min-height: 100svh;
  }
}

/* ----- App ----- */
.app {
  width: 100%;
  max-width: var(--app-max);
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: var(--gap);
}

/* ----- Top Bar ----- */
.topbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.room,
.conn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.label {
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Display ----- */
.display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px 16px;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 14px;
  align-content: start;
}

.minutes {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 26px;
  color: var(--text);
  margin-top: 2px;
}

/* Big time: fixed-position holders, visually "boxless" */
.timeWrap {
  display: grid;
  justify-items: center;
  align-items: start;
}

.timeBoxes {
  display: grid;
  grid-auto-flow: column;
  gap: var(--digit-gap);
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

/* Invisible fixed holders (no visible boxes) */
.digitBox {
  width: var(--digit-w);
  height: var(--digit-h);

  background: transparent;
  border: none;
  border-radius: 0;

  display: grid;
  place-items: center;

  font-size: var(--digit-size);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.95);

  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.dotBox {
  width: var(--dot-w);
  height: var(--digit-h);
  display: grid;
  place-items: center;
  font-size: var(--dot-size);
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
}

/* Splits */
.splits {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(18px, 5vw, 40px);
  row-gap: 12px;
  align-items: center;
  justify-items: start;
  min-width: 0;
}

.splitRow {
  display: grid;
  grid-auto-flow: column;
  column-gap: 10px;
  align-items: baseline;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: clamp(14px, 3.4vw, 18px);
  min-width: 0;
}

.splitLabel {
  color: rgba(255, 255, 255, 0.85);
}

.splitTime {
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Status line */
.event {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  min-height: 18px;
}

/* ----- Controls ----- */
.controls {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  gap: 12px;
}

.row.two {
  grid-template-columns: 1fr 1fr;
}

.row.one {
  grid-template-columns: 1fr;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
  border-radius: 16px;
  padding: 18px 14px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.10em;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn.big {
  padding: 32px 14px;
  font-size: 20px;
}

.btn:active {
  transform: translateY(1px);
  background: var(--btn-active);
}

.btn:hover {
  background: var(--btn-hover);
}

.btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.25);
  outline-offset: 2px;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Variants */
.primary {
  background: rgba(80, 200, 160, 0.14);
  border-color: rgba(80, 200, 160, 0.28);
}

.primary:hover {
  background: rgba(80, 200, 160, 0.18);
}

.danger {
  background: rgba(255, 90, 90, 0.14);
  border-color: rgba(255, 90, 90, 0.28);
}

.danger:hover {
  background: rgba(255, 90, 90, 0.18);
}

.info {
  background: rgba(0, 170, 255, 0.18);
  border-color: rgba(0, 170, 255, 0.30);
}

.info:hover {
  background: rgba(0, 170, 255, 0.22);
}

.ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

/* ----- Footer ----- */
.footer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.share {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.tagline {
  margin: 0;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
}

/* Screen-reader only */
.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Small-screen tightening (keeps the exact same layout, just reduces wasted space) */
@media (max-width: 380px) {
  .display {
    padding: 16px 12px 14px;
    gap: 12px;
  }

  .controls {
    padding: 12px;
  }

  .btn.big {
    padding: 28px 14px;
    font-size: 19px;
  }
}