:root {
  --ink: #202124;
  --muted: #687076;
  --paper: #fbf7ef;
  --panel: #ffffff;
  --line: #ded7cb;
  --owl: #476a91;
  --lark: #a6573f;
  --blitz: #3c8068;
  --gold: #d8a83f;
  --shadow: 0 22px 70px rgba(33, 29, 23, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(rgba(251, 247, 239, 0.9), rgba(251, 247, 239, 0.9)),
    url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d9cdbb' stroke-width='2' opacity='.55'%3E%3Cpath d='M26 55c12-16 31-16 42 0M92 55c12-16 31-16 42 0M40 85h80M48 105h64M38 35l18-16 18 16M86 35l18-16 18 16'/%3E%3C/g%3E%3C/svg%3E");
}

button,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #ffffff;
  background: #2e3133;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(32, 33, 36, 0.16);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

.app-shell {
  width: min(1120px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 18px;
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
}

.ghost-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.round-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.round-step {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  align-content: center;
  gap: 3px;
}

.round-step strong {
  font-size: 0.9rem;
}

.round-step span {
  color: var(--muted);
  font-size: 0.78rem;
}

.round-step.active {
  color: #ffffff;
  border-color: transparent;
}

.round-step.active span {
  color: rgba(255, 255, 255, 0.78);
}

.round-step.owl.active {
  background: var(--owl);
}

.round-step.lark.active {
  background: var(--lark);
}

.round-step.blitz.active {
  background: var(--blitz);
}

.table-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: stretch;
}

.card-stage {
  min-height: 500px;
  border-radius: 8px;
  padding: clamp(22px, 4vw, 48px);
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(222, 215, 203, 0.72);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 26px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.card-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(216, 168, 63, 0.2), transparent 32%),
    radial-gradient(circle at top right, rgba(71, 106, 145, 0.12), transparent 34%);
}

.card-stage.is-hidden::before {
  background:
    linear-gradient(135deg, rgba(71, 106, 145, 0.96), rgba(60, 128, 104, 0.94)),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='2' opacity='.25'%3E%3Cpath d='M23 44c9-11 22-11 30 0M67 44c9-11 22-11 30 0M34 65h52M42 80h36M31 28l13-12 13 12M63 28l13-12 13 12'/%3E%3C/g%3E%3C/svg%3E");
}

.card-stage.is-hidden.lark::before {
  background:
    linear-gradient(135deg, rgba(166, 87, 63, 0.96), rgba(216, 168, 63, 0.9)),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='2' opacity='.25'%3E%3Cpath d='M23 44c9-11 22-11 30 0M67 44c9-11 22-11 30 0M34 65h52M42 80h36M31 28l13-12 13 12M63 28l13-12 13 12'/%3E%3C/g%3E%3C/svg%3E");
}

.card-stage.is-hidden.blitz::before {
  background:
    linear-gradient(135deg, rgba(60, 128, 104, 0.98), rgba(71, 106, 145, 0.9)),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='2' opacity='.25'%3E%3Cpath d='M23 44c9-11 22-11 30 0M67 44c9-11 22-11 30 0M34 65h52M42 80h36M31 28l13-12 13 12M63 28l13-12 13 12'/%3E%3C/g%3E%3C/svg%3E");
}

.card-stage.lark::before {
  background:
    linear-gradient(90deg, rgba(166, 87, 63, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(216, 168, 63, 0.15), transparent 34%);
}

.card-stage.blitz::before {
  background:
    linear-gradient(90deg, rgba(60, 128, 104, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(71, 106, 145, 0.14), transparent 34%);
}

.card-meta,
.card-body,
.goal-text {
  position: relative;
  z-index: 1;
}

.card-back {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #ffffff;
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  transition: opacity 180ms ease, transform 180ms ease;
}

.card-back span {
  padding: 18px 22px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.card-stage.is-hidden .card-meta,
.card-stage.is-hidden .card-body,
.card-stage.is-hidden .goal-text {
  opacity: 0;
}

.card-stage:not(.is-hidden) .card-back {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

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

.round-status span + span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.round-pill {
  display: inline-grid;
  place-items: center;
  min-width: 112px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--owl);
  font-weight: 700;
}

.round-pill.lark {
  background: var(--lark);
}

.round-pill.blitz {
  background: var(--blitz);
}

.card-body {
  display: grid;
  align-content: center;
  gap: 18px;
}

.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-body h2 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 6.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.blitz-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.blitz-item {
  min-height: 58px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f3efe7;
  border: 1px solid var(--line);
  font-size: clamp(1.05rem, 2.5vw, 1.45rem);
  font-weight: 700;
  display: flex;
  align-items: center;
}

.goal-text {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.45;
}

.timer-panel {
  min-height: 500px;
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 18px;
}

.timer-face {
  border-radius: 8px;
  background: #202124;
  color: #ffffff;
  display: grid;
  place-items: center;
  min-height: 210px;
  font-size: clamp(3.4rem, 9vw, 5.7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.timer-face.finished {
  background: var(--gold);
  color: #202124;
}

.timer-select {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

select {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.timer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.timer-actions button {
  padding: 0 10px;
}

.primary-button {
  flex: 1;
  background: #1d5f50;
}

.controls button:not(.primary-button) {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding: 10px 0;
    gap: 8px;
  }

  .topbar {
    align-items: center;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1.85rem;
    line-height: 1;
  }

  button {
    min-height: 42px;
  }

  .topbar .ghost-button {
    min-width: 108px;
    padding: 0 12px;
  }

  .round-track {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .round-step {
    min-height: 34px;
    padding: 5px 4px;
    text-align: center;
  }

  .round-step strong {
    font-size: 0.72rem;
  }

  .round-step span {
    display: none;
  }

  .table-area {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .card-stage,
  .timer-panel {
    min-height: auto;
  }

  .card-stage {
    min-height: 250px;
    padding: 15px;
    gap: 12px;
  }

  .card-meta {
    font-size: 0.86rem;
  }

  .round-pill {
    min-width: 96px;
    min-height: 30px;
    padding: 0 10px;
  }

  .card-body {
    gap: 8px;
  }

  .card-body h2 {
    font-size: clamp(1.75rem, 8vw, 3.2rem);
    line-height: 1.04;
  }

  .goal-text {
    font-size: 0.92rem;
    line-height: 1.28;
  }

  .timer-panel {
    grid-template-columns: 118px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
  }

  .timer-face {
    grid-row: 1 / span 2;
    min-height: 96px;
    font-size: 2.25rem;
  }

  .timer-select {
    gap: 4px;
    font-size: 0.85rem;
  }

  select {
    min-height: 38px;
  }

  .timer-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .timer-actions button {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.9rem;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }
}

@media (max-width: 520px) {
  .topbar {
    display: flex;
  }

  .round-track {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .card-meta {
    align-items: center;
    flex-direction: row;
  }

  .round-status {
    justify-content: flex-end;
    gap: 6px;
    font-size: 0.78rem;
  }

  .round-status span + span {
    padding-left: 6px;
  }

  .blitz-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .blitz-item {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  .timer-panel {
    grid-template-columns: 1fr;
  }

  .timer-face {
    grid-row: auto;
  }
}
