:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
  color: #f3f5f8;
  --accent: #7be8c2;
  --accent-strong: #2dd4bf;
  --accent-deep: #0d9488;
}

:root[data-theme="light"] {
  color-scheme: light;
  background: #fafcfb;
  color: #1b262c;
  --accent: #0d7356;
  --accent-strong: #0d7356;
  --accent-deep: #0a5841;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #f3f5f8;
  isolation: isolate;
}

[data-theme="light"] body {
  background: #fafcfb;
  color: #1b262c;
}

/* Ambient Background Glows (TG Timer Signature) */
.ambience {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.glow {
  position: absolute;
  width: min(44vw, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: .18;
  animation: drift 22s ease-in-out infinite alternate;
}

.glow-mint {
  background: radial-gradient(circle, #51d6aa, transparent 68%);
  top: 12%;
  left: -12%;
}

.glow-blue {
  background: radial-gradient(circle, #6b82ef, transparent 68%);
  right: -10%;
  bottom: -12%;
  animation-delay: -11s;
  animation-duration: 28s;
}

@keyframes drift {
  from { opacity: .08; }
  to { opacity: .18; }
}

[data-theme="light"] .glow {
  opacity: .12;
}

/* Sweep hover shimmer for interactive buttons & cards */
button, .btn-shimmer {
  font: inherit;
  cursor: pointer;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  touch-action: manipulation;
  text-decoration: none;
}

button::before, .btn-shimmer::before {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: 65%;
  height: 200%;
  top: -50%;
  left: -80%;
  background: linear-gradient(110deg, transparent 10%, #ffffff08 25%, #ffffff55 50%, #ffffff08 75%, transparent 90%);
  filter: blur(16px);
  transform: skewX(-20deg);
  opacity: 0;
  transition: left .75s ease, opacity .35s ease;
}

button:hover::before,
button:focus-visible::before,
.btn-shimmer:hover::before,
.btn-shimmer:focus-visible::before {
  left: 65%;
  opacity: .85;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 5px;
}

/* Header */
header {
  padding: max(14px, env(safe-area-inset-top)) clamp(14px, 4vw, 40px) 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  border-bottom: 1px solid #ffffff0d;
  width: 100%;
}

[data-theme="light"] header {
  border-color: #1b262c25;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  padding: 2px 4px 2px 0;
  transition: opacity .15s ease;
}

.brand-lockup:hover {
  opacity: .92;
}

.brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 7px;
  display: block;
}

[data-theme="light"] .brand-icon rect {
  fill: #ffffff;
}

[data-theme="light"] .brand-icon g {
  stroke: #0d7356;
}

.brand-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.5px;
  color: #f3f5f8;
  white-space: nowrap;
}

[data-theme="light"] .brand-title {
  color: #1b262c;
}

.brand-word {
  font-weight: 400;
  color: #9ba5b5;
}

[data-theme="light"] .brand-word {
  color: #536672;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

.wall-clock {
  padding-right: 12px;
  border-right: 1px solid #ffffff26;
  color: #d5e9e2;
  font: 17px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
  white-space: nowrap;
  flex-shrink: 0;
}

[data-theme="light"] .wall-clock {
  color: #1b262c;
  border-color: #1b262c25;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #ffffff26;
  background: linear-gradient(135deg, #ffffff12, #ffffff05);
  color: #e6edf4;
  transition: background .15s, border-color .15s, transform .15s;
}

.theme-toggle-btn::before {
  content: none;
}

.theme-toggle-btn:hover {
  background: #ffffff1f;
  border-color: #ffffff44;
}

.theme-toggle-btn:active {
  transform: scale(.93);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
}

[data-theme="light"] .theme-toggle-btn {
  color: #344b55;
  background: linear-gradient(135deg, #fff, #eaf0ee);
  border-color: #1b262c35;
}

[data-theme="light"] .theme-toggle-btn:hover {
  background: #e4eee9;
}

/* Main Content */
main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  width: min(100%, 700px);
  text-align: center;
  animation: page-in .28s cubic-bezier(.16, 1, .3, 1);
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(12px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0 0 14px;
}

h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 550;
  letter-spacing: -1.8px;
  margin: 0 0 14px;
}

.intro {
  color: #9ba5b5;
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

[data-theme="light"] .intro {
  color: #536672;
}

/* TG Timer Glass Shell */
.clock-shell {
  border: 1px solid #ffffff23;
  background: linear-gradient(135deg, #ffffff0c, #ffffff03);
  box-shadow: inset 0 1px 0 #ffffff0e, 0 24px 60px #0006;
  border-radius: 24px;
  padding: 36px clamp(18px, 5vw, 44px);
  margin-top: 32px;
}

[data-theme="light"] .clock-shell {
  background: linear-gradient(135deg, #fff, #edf4f1);
  border-color: #1b262c28;
  box-shadow: inset 0 1px 0 #fff, 0 18px 45px #2646370a;
}

/* Spelling Bee Book Launcher Button (matches TG Timer .study-graph-btn) */
.book-list-wrap {
  width: 100%;
  max-width: 540px;
  margin: 36px auto 0;
}

.book-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(123, 232, 194, 0.12) 0%, rgba(13, 148, 136, 0.06) 100%);
  border: 1px solid rgba(123, 232, 194, 0.34);
  border-radius: 18px;
  color: #f3f5f8;
  text-align: left;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.book-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(123, 232, 194, 0.18) 0%, rgba(13, 148, 136, 0.11) 100%);
  border-color: rgba(123, 232, 194, 0.58);
  box-shadow: 0 10px 30px rgba(123, 232, 194, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.book-btn:active {
  transform: scale(.98);
}

.book-btn-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.book-btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(123, 232, 194, 0.15);
  border: 1px solid rgba(123, 232, 194, 0.32);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.book-btn-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.book-btn-title {
  font-size: 16.5px;
  font-weight: 650;
  color: #f3f5f8;
  letter-spacing: -.1px;
}

.book-btn-desc {
  font-size: 13px;
  color: #9ba5b5;
}

.book-btn-arrow {
  color: var(--accent);
  opacity: .85;
  flex-shrink: 0;
  transition: transform .22s cubic-bezier(.16, 1, .3, 1), opacity .15s;
}

.book-btn:hover .book-btn-arrow {
  transform: translateX(4px);
  opacity: 1;
}

[data-theme="light"] .book-btn {
  background: linear-gradient(135deg, rgba(13, 115, 86, 0.08) 0%, rgba(13, 115, 86, 0.03) 100%);
  border-color: rgba(13, 115, 86, 0.28);
  color: #1b262c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .book-btn:hover {
  background: linear-gradient(135deg, rgba(13, 115, 86, 0.13) 0%, rgba(13, 115, 86, 0.06) 100%);
  border-color: rgba(13, 115, 86, 0.48);
  box-shadow: 0 8px 24px rgba(13, 115, 86, 0.12);
}

[data-theme="light"] .book-btn-icon {
  background: rgba(13, 115, 86, 0.12);
  border-color: rgba(13, 115, 86, 0.25);
  color: #0d7356;
}

[data-theme="light"] .book-btn-title {
  color: #1b262c;
}

[data-theme="light"] .book-btn-desc {
  color: #536672;
}

/* Back pill button & Controls */
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  background: #ffffff05;
  border: 1px solid #ffffff14;
  box-shadow: inset 0 1px 0 #ffffff08;
  color: #aab3c2;
  padding: 10px 18px;
  margin-bottom: 24px;
  font-size: 14px;
  border-radius: 999px;
  transition: transform .16s cubic-bezier(.2, .8, .2, 1), background .18s ease, color .18s ease;
}

.back:hover {
  color: #fff;
  background: #ffffff0a;
  transform: translateX(-3px);
}

.back:active {
  transform: translateX(-5px) scale(.96);
}

.back svg {
  width: 18px;
  height: 18px;
}

[data-theme="light"] .back {
  color: #344b55;
  background: linear-gradient(135deg, #fff, #eaf0ee);
  border-color: #1b262c35;
}

[data-theme="light"] .back:hover {
  color: #0d7356;
  background: #e4eee9;
}

.control {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 600;
  transition: background .15s, transform .1s, box-shadow .15s;
}

.control:active {
  transform: scale(.96);
}

.primary {
  background: linear-gradient(135deg, #7be8c238, #7be8c216);
  color: #aaf8dc;
  border: 1px solid #7be8c266;
  box-shadow: inset 0 1px 0 #d8fff840, 0 6px 24px #7be8c20a;
}

.primary:hover {
  background: linear-gradient(135deg, #7be8c24a, #7be8c226);
  box-shadow: inset 0 1px 0 #d8fff860, 0 6px 28px #7be8c21a;
}

[data-theme="light"] .primary {
  color: #0d634d;
  background: linear-gradient(135deg, #c9eadc, #e4f3eb);
  border-color: #0d735660;
  box-shadow: inset 0 1px 0 #fff9;
}

/* Spelling Bee Status Card */
.status-badge-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  border: 1px solid #7be8c255;
  background: #7be8c212;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
}

[data-theme="light"] .status-badge-icon {
  border-color: #0d735644;
  background: #0d735612;
}

.empty-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  margin: 18px 0 10px;
  border-radius: 999px;
  background: rgba(123, 232, 194, 0.08);
  border: 1px solid rgba(123, 232, 194, 0.28);
  color: #f3f5f8;
  font-size: 16px;
  font-weight: 550;
}

[data-theme="light"] .empty-status-pill {
  background: rgba(13, 115, 86, 0.08);
  border-color: rgba(13, 115, 86, 0.25);
  color: #1b262c;
}

.empty-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.status-note {
  color: #9ba5b5;
  font-size: 14px;
  line-height: 1.55;
  margin: 8px auto 26px;
  max-width: 420px;
}

[data-theme="light"] .status-note {
  color: #536672;
}

/* Footer */
footer {
  text-align: center;
  color: #7f8a9c;
  font-size: 14px;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

[data-theme="light"] footer {
  color: #536672;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .glow {
    width: 85vw;
  }
  .wall-seconds {
    display: none;
  }
  header {
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  }
  .brand-icon {
    width: 28px;
    height: 28px;
  }
  .brand-title {
    font-size: 17px;
  }
  .wall-clock {
    font-size: 14px;
    padding-right: 10px;
  }
  main {
    padding: 28px 16px;
  }
  h1 {
    font-size: clamp(26px, 7vw, 34px);
    letter-spacing: -1px;
  }
  .eyebrow {
    font-size: 12px;
    letter-spacing: 2px;
  }
  .clock-shell {
    padding: 28px 18px;
    border-radius: 20px;
  }
  .book-btn {
    padding: 14px 16px;
    border-radius: 16px;
  }
  .book-btn-icon {
    width: 40px;
    height: 40px;
  }
  .book-btn-title {
    font-size: 15.5px;
  }
  footer {
    font-size: 13px;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before {
    transition: none !important;
    animation: none !important;
  }
}
