/* ══ MAIN APP ══ */

#app {
  position: relative;
  z-index: 10;
  width: min(400px, calc(100vw - 32px));
  padding: clamp(28px, 7vw, 50px) clamp(20px, 6vw, 40px) clamp(20px, 5vw, 30px);
  text-align: center;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#app:hover {
  transform: translateY(-5px);
}

/* ── User bar ── */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 2px;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

.sync-dot.syncing {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  animation: spin 0.7s linear infinite;
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Heading ── */
h1 {
  font-weight: 500;
  font-size: clamp(0.72rem, 2.5vw, 0.9rem);
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ── Timer display ── */
#timer {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(60px, 18vw, 80px);
  font-weight: 200;
  line-height: 1;
  margin-bottom: clamp(28px, 7vw, 40px);
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 10px 30px rgba(255, 255, 255, 0.1);
  background: linear-gradient(to bottom, #ffffff, #a1a1aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Control buttons ── */
.buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(24px, 6vw, 40px);
}

button.ctrl {
  flex: 1;
  padding: clamp(13px, 3.5vw, 16px) 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  font-size: clamp(11px, 3vw, 13px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}

button.ctrl.start:hover,
button.ctrl.start:focus-visible {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #fff;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
  outline: none;
}

button.ctrl.pause:hover,
button.ctrl.pause:focus-visible {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fff;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
  outline: none;
}

button.ctrl.reset:hover,
button.ctrl.reset:focus-visible {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fff;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
  outline: none;
}

button.ctrl:active {
  transform: scale(0.92);
}

/* ── Stats row ── */
.stats-container {
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.stat-box       { text-align: left; }
.stat-box.right { text-align: right; }

.stat-label {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 5px;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

#total-stats   { color: #60a5fa; }
#session-stats { color: #f472b6; text-shadow: 0 0 10px rgba(244, 114, 182, 0.3); }

/* ── Mobile tweaks ── */
@media (max-width: 479px) {
  #app {
    /* Stick to bottom of screen on small phones */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 30px 30px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: none !important;
  }

  .user-email {
    max-width: 120px;
  }
}