:root {
  --ink: #111111;
  --panel-idle: #fff1cc;
  --panel-running: #73f28a;
  --panel-stopped: #ff8e5e;
  --tile: #f7f3eb;
  --tile-disabled: #bdbdbd;
  --line: 4px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ink);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 55fr) minmax(0, 25fr) minmax(0, 20fr);
  gap: 0;
}

@keyframes timer-alert-background {
  0%,
  49% {
    background: #ff2a2a;
  }

  50%,
  100% {
    background: #111111;
  }
}

.panel {
  min-height: 0;
  overflow: hidden;
}

.timer-panel {
  width: 100%;
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-idle);
  border-bottom: var(--line) solid var(--ink);
  user-select: none;
  touch-action: manipulation;
}

.timer-panel:focus-visible,
.lesson-tab:focus-visible,
.exam-tab:focus-visible {
  outline: 0;
}

.timer-panel[data-mode="running"] {
  background: var(--panel-running);
}

.timer-panel[data-mode="stopped"] {
  background: var(--panel-stopped);
}

.timer-panel[data-alert="true"] {
  animation: timer-alert-background 800ms steps(1, end) infinite;
}

.timer-panel__status {
  position: absolute;
  top: max(env(safe-area-inset-top), 14px);
  left: 14px;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 6px 8px;
  color: #ffffff;
  background: var(--ink);
}

.timer-panel__display {
  font-size: clamp(4.6rem, 22vw, 8rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums;
}

.timer-panel[data-alert="true"] .timer-panel__display {
  color: #ffffff;
}

.timer-panel__summary {
  position: absolute;
  top: max(env(safe-area-inset-top), 14px);
  right: 14px;
  max-width: 52vw;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
  text-transform: uppercase;
  padding: 6px 8px;
  color: #ffffff;
  background: var(--ink);
}

.timer-panel__message {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: max(env(safe-area-inset-bottom), 14px);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  padding: 6px 8px;
  color: #ffffff;
  background: var(--ink);
}

.lesson-grid {
  height: 100%;
  display: grid;
  gap: var(--line);
  background: var(--ink);
}

.lesson-grid--tyt {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: 1fr;
}

.lesson-grid--ayt {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.lesson-tab,
.exam-tab {
  appearance: none;
  background: var(--tile);
  color: var(--ink);
  min-width: 0;
  font-weight: 900;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.05;
  text-transform: uppercase;
  user-select: none;
  touch-action: manipulation;
}

.lesson-tab {
  width: 100%;
  min-height: 0;
  padding: 14px 6px;
  font-size: clamp(1rem, 4.2vw, 1.45rem);
}

.lesson-grid--tyt .lesson-tab {
  font-size: clamp(0.9rem, 3.6vw, 1.2rem);
}

.lesson-grid--ayt .lesson-tab {
  font-size: clamp(1.15rem, 4.8vw, 1.7rem);
}

.exam-tab {
  width: 100%;
  min-height: 0;
  padding: 16px 8px;
  font-size: clamp(1.5rem, 6vw, 2rem);
}

.lesson-tab.is-active,
.exam-tab.is-active {
  color: #ffffff;
}

.lesson-tab[data-category="TYT_TURKCE"] {
  background: #ffe59a;
}

.lesson-tab[data-category="TYT_SOSYAL"] {
  background: #cfe8ff;
}

.lesson-tab[data-category="TYT_MATEMATIK"] {
  background: #d9f7df;
}

.lesson-tab[data-category="TYT_FEN"] {
  background: #e9dcff;
}

.lesson-tab[data-category="AYT_MATEMATIK"] {
  background: #d9f7df;
}

.lesson-tab[data-category="AYT_FEN"] {
  background: #ffd7c9;
}

.lesson-tab.is-active[data-category="TYT_TURKCE"] {
  background: #d97706;
}

.lesson-tab.is-active[data-category="TYT_SOSYAL"] {
  background: #0284c7;
}

.lesson-tab.is-active[data-category="TYT_MATEMATIK"] {
  background: #059669;
}

.lesson-tab.is-active[data-category="TYT_FEN"] {
  background: #7c3aed;
}

.lesson-tab.is-active[data-category="AYT_MATEMATIK"] {
  background: #059669;
}

.lesson-tab.is-active[data-category="AYT_FEN"] {
  background: #ea580c;
}

.exam-tab[data-exam="TYT"] {
  background: #dce7ff;
}

.exam-tab[data-exam="AYT"] {
  background: #ffd8e8;
}

.exam-tab.is-active[data-exam="TYT"] {
  background: #3454d1;
}

.exam-tab.is-active[data-exam="AYT"] {
  background: #d6336c;
}

.lesson-tab:not(.is-active):disabled,
.exam-tab:not(.is-active):disabled {
  color: var(--ink);
  background: var(--tile-disabled);
  cursor: not-allowed;
}

.lesson-tab.is-active:disabled,
.exam-tab.is-active:disabled {
  cursor: not-allowed;
  filter: grayscale(0.08);
}

.lessons-panel {
  background: var(--ink);
  border-bottom: var(--line) solid var(--ink);
}

.exam-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--line);
  background: var(--ink);
}

@media (min-width: 768px) {
  .timer-panel__status,
  .timer-panel__summary,
  .timer-panel__message {
    font-size: 0.95rem;
  }
}
