:root {
  --bg: #f4f7f2;
  --bg-alt: #e6f1ec;
  --card: rgba(255, 255, 255, 0.86);
  --card-strong: #ffffff;
  --line: rgba(23, 32, 29, 0.12);
  --text: #17201d;
  --muted: #65726d;
  --accent: #e94d2f;
  --accent-2: #087f73;
  --success: #16784f;
  --shadow: 0 24px 70px rgba(30, 43, 38, 0.16);
}

:root[data-theme="dark"] {
  --bg: #111615;
  --bg-alt: #18201d;
  --card: rgba(22, 28, 26, 0.9);
  --card-strong: #1b2421;
  --line: rgba(245, 247, 242, 0.14);
  --text: #f7f8f3;
  --muted: #a8b3ad;
  --accent: #ff7048;
  --accent-2: #35c2a8;
  --success: #69d39e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(8, 127, 115, 0.18) 0%, transparent 32%),
    linear-gradient(165deg, var(--bg) 0%, #fbfaf3 54%, #eef5f8 100%);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(53, 194, 168, 0.16) 0%, transparent 32%),
    linear-gradient(165deg, var(--bg) 0%, #171d1b 54%, #121816 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 32, 29, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 29, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #f1c64b);
  color: #ffffff;
  font-weight: 800;
}

.brand-text,
.eyebrow,
.status-pill,
.control-btn,
.ghost-btn,
.language-button,
.language-option {
  letter-spacing: 0;
}

.brand-text {
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-picker {
  position: relative;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
}

:root[data-theme="dark"] .language-picker {
  background: rgba(28, 36, 33, 0.72);
}

.language-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.flag-img {
  width: 26px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(23, 32, 29, 0.14);
}

.select-chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.language-menu {
  position: absolute;
  z-index: 2000;
  top: calc(100% + 8px);
  right: 0;
  width: min(260px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
}

.language-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.language-option:hover,
.language-option[aria-selected="true"] {
  background: rgba(8, 127, 115, 0.09);
}

:root[data-theme="dark"] .language-option:hover,
:root[data-theme="dark"] .language-option[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.08);
}

.theme-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 1.35rem;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.theme-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: rgba(23, 32, 29, 0.24);
}

:root[data-theme="dark"] .theme-toggle {
  background: rgba(28, 36, 33, 0.72);
}

:root[data-theme="dark"] .theme-toggle:hover {
  background: #24302c;
  border-color: rgba(245, 247, 242, 0.24);
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(420px, 760px);
  grid-template-areas:
    "copy"
    "timer";
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.hero-copy {
  grid-area: copy;
  min-width: 0;
  padding: 8px 0 4px;
  text-align: center;
}

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 14px;
}

.hero-copy h1 {
  font-family: "Syne", sans-serif;
  font-size: clamp(2.1rem, 4.8vw, 4.8rem);
  line-height: 1;
  margin: 0 auto;
  max-width: 12ch;
  overflow-wrap: break-word;
}

.stopwatch-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.stopwatch-card {
  grid-area: timer;
  min-width: 0;
  overflow: hidden;
  border-radius: 32px;
  padding: clamp(18px, 3vw, 28px);
}

.stopwatch-glow {
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  pointer-events: none;
}

.display-meta,
.laps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(22, 120, 79, 0.1);
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 700;
}

.hint-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.display-wrap {
  padding: 30px 0 22px;
}

.time-display {
  font-family: "Courier New", "Consolas", monospace;
  font-size: clamp(2.35rem, 7vw, 5.4rem);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  white-space: nowrap;
  padding: clamp(20px, 4vw, 30px) 12px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(8, 127, 115, 0.06), rgba(233, 77, 47, 0.04)),
    var(--card-strong);
  border: 1px solid rgba(23, 32, 29, 0.08);
  overflow-wrap: anywhere;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 12px;
}

.control-btn,
.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.64);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.control-btn {
  min-height: 58px;
  padding: 14px 12px;
  min-width: 0;
  white-space: normal;
}

.control-btn:hover,
.ghost-btn:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: rgba(23, 32, 29, 0.24);
}

:root[data-theme="dark"] .control-btn,
:root[data-theme="dark"] .ghost-btn {
  background: rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .control-btn:hover,
:root[data-theme="dark"] .ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(245, 247, 242, 0.24);
}

.control-btn.primary {
  background: linear-gradient(135deg, var(--accent), #ff8f51);
  border-color: transparent;
  color: #ffffff;
}

.laps-panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(23, 32, 29, 0.08);
}

:root[data-theme="dark"] .laps-panel {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(245, 247, 242, 0.18);
}

.laps-header h2 {
  margin: 0;
  font-size: 1rem;
}

.ghost-btn {
  min-height: 40px;
  padding: 8px 14px;
}

.laps-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 10px;
}

.laps-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(8, 127, 115, 0.06);
}

:root[data-theme="dark"] .laps-list li {
  background: rgba(255, 255, 255, 0.11);
}

.lap-label {
  color: var(--muted);
}

:root[data-theme="dark"] .lap-label,
:root[data-theme="dark"] .empty-state {
  color: #c7d0cb;
}

.empty-state {
  margin: 16px 0 0;
  color: var(--muted);
}

.site-footer {
  padding: 28px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 980px) {
  .hero-layout {
    grid-template-areas:
      "copy"
      "timer";
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 20px, 100%);
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    flex-wrap: nowrap;
    justify-content: stretch;
  }

  .language-picker {
    flex: 1;
    justify-content: space-between;
    min-width: 0;
  }

  .language-button {
    min-width: 0;
    flex: 1;
  }

  .stopwatch-card {
    padding: 18px;
    border-radius: 24px;
  }

  .time-display {
    font-size: clamp(1.75rem, 9.8vw, 3.2rem);
    border-radius: 20px;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .display-meta,
  .laps-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .controls {
    grid-template-columns: minmax(0, 1fr);
  }
}
