:root {
  --bg: #f8f4ef;
  --panel: #ffffff;
  --text: #2f251f;
  --muted: #6f6258;
  --line: #ddcec0;
  --brand: #c30000;
  --brand-soft: #f9dddd;
  --accent: #7a6f60;
  --success: #2f7d4f;
  --success-soft: #e3f3e8;
  --danger: #b33632;
  --gold-rim: #b8790f;
  --minute-blue: #1d63d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #fff8f3, var(--bg) 50%);
  min-height: 100vh;
}

h1, h2, p {
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fcf8f3);
  box-shadow: 0 4px 20px rgba(90, 52, 38, 0.08);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.master-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.topbar h1 {
  font-size: 1.5rem;
  color: var(--brand);
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.section-toggle-row {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 0;
}

.section-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
}

.section-toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 999px;
}

.section-toggle-btn.active {
  background: var(--success);
  color: #fff;
}

.tool-toggle-row {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4px 20px 0;
  display: flex;
  justify-content: center;
}

.tool-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
}

.tool-toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 16px;
  min-height: 40px;
  border-radius: 999px;
}

.tool-toggle-btn.active {
  background: var(--brand);
  color: #fff;
}

.timeline-wrap {
  width: 100%;
  padding: 20px 0;
}

.tchart-wrap {
  width: 100%;
  padding: 20px 0;
  display: flex;
  justify-content: center;
}

.tchart-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 360px;
}

.tchart-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  font-size: 0.95rem;
}

.tchart-table th:first-child {
  border-radius: 10px 0 0 0;
}

.tchart-table th:last-child {
  border-radius: 0 10px 0 0;
}

.tchart-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.tchart-table tr:last-child td {
  border-bottom: none;
}

.tchart-table td.tchart-jump {
  color: var(--success);
}

.tchart-table td.tchart-start {
  color: var(--muted);
  font-weight: 600;
  font-style: italic;
}

.clock-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.clock-headline {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.headline-blue {
  color: var(--minute-blue);
}

.skal-tip {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 40ch;
}

.skal-tip strong {
  color: var(--brand);
}

.clock-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  /* Extra breathing room so the Teach Me minute-count badge (and its small
     "minutes" label stacked above/below it) orbiting just outside the gold
     bezel has space before it reaches the headline/buttons. Only the
     Telling Time clock has this orbiting badge - the Elapsed Time clock
     doesn't, so it uses the smaller .elapsed-clock-wrap padding below. */
  padding: 76px 0;
}

.elapsed-clock-wrap {
  padding: 20px 0;
}

.clock-face {
  position: relative;
  width: min(78vmin, 440px);
  aspect-ratio: 1 / 1;
  touch-action: none;
  user-select: none;
}

#clockSvg,
#elapsedClockSvg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 12px 24px rgba(90, 52, 38, 0.22));
}

.bezel {
  fill: url(#bezelGradient);
  stroke: var(--gold-rim);
  stroke-width: 2;
}

.face-bg {
  fill: #fffaf2;
  stroke: #f1e3c8;
  stroke-width: 1.5;
}

.tick-minute {
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.tick-hour {
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
}

.num-label {
  font-weight: 800;
  font-size: 16px;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: central;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.hand polygon {
  pointer-events: none;
}

.hour-hand polygon {
  fill: var(--brand);
}

.minute-hand polygon {
  fill: var(--minute-blue);
}

.hub-ring {
  fill: #fff;
  stroke: var(--text);
  stroke-width: 2;
}

.hub-dot {
  fill: var(--text);
}

/* Teach Me: dims every clock part except the one currently being taught */
#ticks,
#numbers,
.hand {
  transition: opacity 0.4s ease;
}

.teach-dim {
  opacity: 0.12;
}

.teach-glow {
  animation: teach-pulse 1.1s ease-in-out infinite;
}

@keyframes teach-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

.ghost-second-hand polygon {
  fill: var(--accent);
  opacity: 0.6;
}

/* Minute-sweep counting aid: a number briefly pops full-brightness on top of
   the (possibly dimmed) real number as the minute hand reaches it, alongside
   a running 5/10/15... counter - reinforcing that each number is 5 minutes. */
.number-pop-visual {
  font-weight: 900;
  font-size: 22px;
  fill: var(--brand);
  text-anchor: middle;
  dominant-baseline: central;
  transform-box: fill-box;
  transform-origin: center;
  animation: number-pop-in 0.5s ease;
  pointer-events: none;
}

@keyframes number-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  40% {
    opacity: 1;
    transform: scale(1.6);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* The running 5/10/15... count builds up around the outside of the clock as
   the sweep progresses: the just-reached number is large and bold, and each
   earlier one shrinks down to a small, muted label that stays in place -
   so by the end the full skip-count sequence rings the whole clock. */
.counter-badge {
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  transition: font-size 0.35s ease, opacity 0.35s ease, fill 0.35s ease;
}

.counter-badge.current {
  font-size: 26px;
  fill: var(--brand);
  opacity: 1;
  animation: number-pop-in 0.5s ease;
}

.counter-badge.muted {
  font-size: 14px;
  fill: var(--accent);
  opacity: 0.6;
}

/* Only ever exists on the current (large) count, just beyond it - removed
   entirely once that count shrinks down and joins the muted trail. */
.counter-badge-label {
  font-weight: 700;
  font-size: 7px;
  fill: var(--brand);
  text-anchor: middle;
  dominant-baseline: central;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.nudge-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

button.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 18px;
  min-height: 56px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
}

button.ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
}

button.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.ghost:disabled:hover {
  border-color: var(--line);
  color: var(--text);
}

button.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(195, 0, 0, 0.25);
}

button.primary:hover {
  background: #a80000;
}

button.primary.success {
  background: var(--success);
  box-shadow: 0 6px 16px rgba(47, 125, 79, 0.3);
}

button.primary.success:hover {
  background: #256a42;
}

button.secondary {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-soft);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
}

.readout {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.digital {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
}

.written {
  font-size: 1.2rem;
  color: var(--muted);
}

.speak-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 20px;
  min-height: 52px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
}

.speak-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 16px 12px;
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}

.mode-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(90, 52, 38, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card h2 {
  color: var(--brand);
  font-size: 1.2rem;
}

.teach-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.teach-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: var(--line);
  padding: 0;
}

.teach-dot.active {
  background: var(--brand);
  transform: scale(1.25);
}

.teach-dot.done {
  background: var(--success);
}

.teach-caption {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-line;
}

.teach-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.teach-nav .speak-btn {
  flex: 1;
}

#teachCtaBtn {
  width: 100%;
}

.hint-text {
  color: var(--muted);
  line-height: 1.5;
}

.level-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.level-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 18px;
  min-height: 56px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.level-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.direction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.direction-row select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.prompt-box {
  background: var(--brand-soft);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.prompt-label {
  color: var(--brand);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prompt-primary {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.prompt-secondary {
  font-size: 1rem;
  color: var(--muted);
}

.feedback {
  min-height: 1.6rem;
  font-weight: 700;
  text-align: center;
  border-radius: 10px;
  padding: 8px;
  font-size: 1.05rem;
}

.duration-answer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.jump-sum {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  width: 100%;
}

.jump-sum-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: fit-content;
}

.jump-sum-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.jump-sum-row {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  padding: 1px 4px;
  white-space: nowrap;
}

.jump-sum-row.total {
  border-top: 3px solid var(--text);
  margin-top: 4px;
  padding-top: 4px;
  min-width: 1.5em;
  text-align: center;
}

.duration-readout {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.stepper-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

.stepper-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button.stepper-btn {
  padding: 12px 10px;
  min-height: 52px;
  font-size: 0.95rem;
}

.jump-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.jump-btn {
  background: var(--minute-blue);
  color: #fff;
  border: none;
  padding: 14px 10px;
  min-height: 56px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
}

.jump-btn:hover {
  background: #154a9e;
}

.jump-btn.next-hour {
  grid-column: 1 / -1;
  background: var(--brand);
}

.jump-btn.next-hour:hover {
  background: #a80000;
}

.feedback.correct {
  color: var(--success);
  background: var(--success-soft);
  animation: feedback-pop 0.5s ease;
}

@keyframes feedback-pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  60% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.feedback.incorrect {
  color: var(--danger);
  background: #fbe9e8;
}

.practice-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.score-line {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

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

.site-footer a {
  color: var(--brand);
}

@media (min-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: start;
  }
}

/* Below 880px the layout stacks into one column (clock-panel, then
   side-panel), which used to force constant scrolling back and forth
   between a visual (clock/number line/T-chart) and the buttons below it.
   Pinning the visual to the top of the screen while scrolling keeps it in
   view the whole time a student is tapping buttons further down. */
@media (max-width: 879px) {
  .clock-panel {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    gap: 8px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 12px -8px rgba(90, 52, 38, 0.15);
  }

  .clock-headline {
    font-size: 1rem;
  }

  .skal-tip {
    font-size: 0.8rem;
  }

  .timeline-wrap,
  .tchart-wrap,
  .elapsed-clock-wrap {
    padding: 8px 0;
  }
}

@media (min-width: 1300px) {
  .clock-face {
    width: min(60vmin, 520px);
  }
  .topbar h1 {
    font-size: 1.8rem;
  }
  .digital {
    font-size: 2.6rem;
  }
}
