/* ==========================================================================
   Malay Sports Stopwatch - iPhone Native Style
   ========================================================================== */

:root {
  --color-bg: #000000;
  --color-surface: #1C1C1E;
  --color-surface-secondary: #2C2C2E;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #8E8E93;
  --color-text-muted: #636366;
  
  /* iOS Authentic Action Colors */
  --color-start: #30D158;
  --color-start-bg: rgba(48, 209, 88, 0.18);
  --color-start-border: rgba(48, 209, 88, 0.4);
  
  --color-stop: #FF453A;
  --color-stop-bg: rgba(255, 69, 58, 0.18);
  --color-stop-border: rgba(255, 69, 58, 0.4);
  
  --color-reset-bg: #2C2C2E;
  --color-reset-text: #FFFFFF;
  --color-reset-disabled: #1C1C1E;
  --color-reset-disabled-text: #48484A;
  
  --safe-top: env(safe-area-inset-top, 24px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);
  --safe-left: env(safe-area-inset-left, 16px);
  --safe-right: env(safe-area-inset-right, 16px);
  
  /* Button dimension: Giant 170px for sports tap */
  --btn-giant-size: 170px;
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
}

/* Main Container */
.app-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) var(--safe-right) calc(var(--safe-bottom) + 12px) var(--safe-left);
}

/* Header & Logo */
.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding-top: 8px;
  min-height: 54px;
}

.brand-logo {
  max-width: 200px;
  max-height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* Timer Section */
.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  margin-top: -10px;
}

.limit-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Monospace Tabular Numbers Time Readout */
.time-readout {
  font-size: clamp(52px, 14vw, 76px);
  font-weight: 200;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum";
  font-feature-settings: "tnum";
  color: var(--color-text-primary);
  text-align: center;
  line-height: 1;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  transition: transform 0.2s ease, color 0.2s ease;
}

.max-indicator {
  opacity: 0;
  transform: translateY(6px);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--color-start);
  margin-top: 14px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.max-indicator.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Pulse animation on finish */
@keyframes completed-pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(48, 209, 88, 0)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 25px rgba(48, 209, 88, 0.6)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(48, 209, 88, 0)); }
}

.time-readout.is-completed {
  color: var(--color-start);
  animation: completed-pulse 1.2s ease-in-out infinite;
}

/* Controls Section */
.controls-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  gap: 22px;
  padding-bottom: 8px;
}

/* Secondary Reset Button */
.secondary-controls {
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-reset {
  touch-action: manipulation;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background-color: var(--color-reset-bg);
  color: var(--color-reset-text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-reset:disabled {
  background-color: var(--color-reset-disabled);
  color: var(--color-reset-disabled-text);
  border-color: rgba(255, 255, 255, 0.04);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-reset:not(:disabled):active {
  transform: scale(0.92);
  background-color: #3A3A3C;
}

/* Primary Giant Circular Start / Stop Button (~170px) */
.primary-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.btn-giant-action {
  touch-action: manipulation;
  width: var(--btn-giant-size);
  height: var(--btn-giant-size);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.25s ease,
              border-color 0.25s ease,
              box-shadow 0.25s ease;
  position: relative;
  outline: none;
}

/* Outer concentric ring for Apple Watch / iOS Sports Feel */
.btn-giant-action::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.35;
  transition: all 0.25s ease;
}

.btn-label {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
}

/* Start State (Green #30D158) */
.btn-giant-action.is-start {
  background-color: var(--color-start-bg);
  border: 3px solid var(--color-start);
  color: var(--color-start);
  box-shadow: 0 6px 28px rgba(48, 209, 88, 0.35),
              inset 0 0 16px rgba(48, 209, 88, 0.15);
}

.btn-giant-action.is-start::before {
  color: var(--color-start);
}

/* Stop State (Red #FF453A) */
.btn-giant-action.is-stop {
  background-color: var(--color-stop-bg);
  border: 3px solid var(--color-stop);
  color: var(--color-stop);
  box-shadow: 0 6px 28px rgba(255, 69, 58, 0.35),
              inset 0 0 16px rgba(255, 69, 58, 0.15);
}

.btn-giant-action.is-stop::before {
  color: var(--color-stop);
}

/* Completed State (when 1 minute reached) */
.btn-giant-action.is-completed {
  background-color: var(--color-surface);
  border: 3px solid var(--color-text-secondary);
  color: var(--color-text-secondary);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-giant-action.is-completed::before {
  color: var(--color-text-secondary);
  opacity: 0.15;
}

/* Instant Touch Press Feedback */
.btn-giant-action:active:not(.is-completed) {
  transform: scale(0.93);
}

/* Footer / Tips */
.app-footer {
  width: 100%;
  text-align: center;
  padding-top: 6px;
}

.status-tip {
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.3px;
}

/* Responsive adjustments for smaller screens (iPhone SE) */
@media (max-height: 680px) {
  :root {
    --btn-giant-size: 145px;
  }
  .time-readout {
    font-size: 48px;
  }
  .btn-reset {
    width: 66px;
    height: 66px;
    font-size: 12px;
  }
  .btn-label {
    font-size: 20px;
  }
  .controls-section {
    gap: 14px;
  }
}
