:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --text: #172033;
  --muted: #667085;
  --line: #dbe3ec;
  --primary: #0f7b6c;
  --primary-dark: #095f55;
  --accent: #f4b740;
  --danger: #c64242;
  --success: #0b8f5a;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 123, 108, 0.18), transparent 36rem),
    linear-gradient(135deg, #f7fbff 0%, #eef4f0 100%);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(22px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.game {
  width: min(100%, 460px);
  min-height: min(760px, calc(100vh - 44px));
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(219, 227, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.level-pill {
  flex: 0 0 auto;
  min-width: 86px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}

.level-pill strong {
  min-width: 24px;
  font-size: 20px;
  color: var(--text);
  text-align: center;
}

.progress-wrap {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-meta strong {
  color: var(--text);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6ee;
}

.progress-bar {
  height: 100%;
  min-width: 1%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 220ms ease;
}

.timer-panel {
  flex: 1;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
}

.target-label {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.target-time {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dark);
}

.timer {
  width: 100%;
  margin: 28px 0 14px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(48px, 17vw, 78px);
  line-height: 1;
  font-weight: 850;
  text-align: center;
  color: var(--text);
}

.timer.running {
  color: var(--danger);
}

.hint {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.result-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.result-title {
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 800;
}

.result-title.success {
  color: var(--success);
}

.result-title.failed {
  color: var(--danger);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.result-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.result-grid strong {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  gap: 10px;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(15, 123, 108, 0.26);
}

.primary-btn:hover,
.primary-btn:focus-visible {
  background: var(--primary-dark);
}

.primary-btn.danger {
  background: var(--danger);
  box-shadow: 0 12px 24px rgba(198, 66, 66, 0.22);
}

.secondary-btn {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.secondary-btn:hover,
.secondary-btn:focus-visible {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.rules {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .game {
    padding: 16px;
    gap: 14px;
  }

  h1 {
    font-size: 21px;
  }

  .level-pill {
    min-width: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
