:root {
  --bg-top: #fff6d8;
  --bg-bottom: #ffe1b7;
  --panel-bg: rgba(255, 252, 245, 0.82);
  --panel-border: rgba(186, 136, 79, 0.18);
  --text-main: #4a2f1b;
  --text-soft: #7b5a40;
  --accent: #f06d38;
  --accent-deep: #cf4f1d;
  --accent-calm: #2d9c8f;
  --shadow: 0 24px 60px rgba(113, 68, 25, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "PingFang SC", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 30%),
    radial-gradient(circle at bottom right, rgba(240, 109, 56, 0.14), transparent 25%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(8px);
  z-index: 0;
}

body::before {
  top: 48px;
  right: 8%;
  background: rgba(255, 196, 102, 0.2);
}

body::after {
  left: 5%;
  bottom: 32px;
  background: rgba(45, 156, 143, 0.12);
}

.app {
  position: relative;
  z-index: 1;
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.page-header {
  margin-bottom: 16px;
  text-align: center;
}

.page-title {
  margin: 0;
  font-size: clamp(2rem, 4.6vw, 3rem);
  line-height: 1.15;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  text-shadow: 0 10px 24px rgba(207, 79, 29, 0.12);
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.controls-panel {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
}

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

.duration-field {
  align-items: flex-start;
}

.field label {
  font-size: 0.95rem;
  color: var(--text-soft);
}

.toggle-field {
  justify-content: end;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid rgba(45, 156, 143, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  white-space: nowrap;
}

.toggle-option input {
  margin: 0;
  accent-color: var(--accent-calm);
}

.duration-control {
  width: 80px;
  height: 44px;
  padding: 0 28px 0 12px;
  border: 2px solid rgba(240, 109, 56, 0.18);
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.9);
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-deep) 50%),
    linear-gradient(135deg, var(--accent-deep) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.minutes-control {
  width: 92px;
}

.duration-control:focus {
  outline: none;
  border-color: rgba(240, 109, 56, 0.55);
  box-shadow: 0 0 0 4px rgba(240, 109, 56, 0.12);
}

.button-group {
  display: flex;
  gap: 12px;
}

button {
  min-width: 96px;
  height: 44px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 16px 28px rgba(240, 109, 56, 0.28);
}

.secondary-button {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(74, 47, 27, 0.12);
}

.display-panel {
  margin-top: 16px;
  padding: 22px;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.status-pill {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  color: #fff;
  background: rgba(45, 156, 143, 0.84);
}

.practice-card {
  display: flex;
  flex-direction: column;
  min-height: 380px;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 246, 230, 0.96)),
    repeating-linear-gradient(
      -18deg,
      rgba(240, 109, 56, 0.04),
      rgba(240, 109, 56, 0.04) 16px,
      transparent 16px,
      transparent 32px
    );
  border: 1px solid rgba(240, 109, 56, 0.12);
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}

.practice-card.show-answer {
  transform: translateY(-2px);
  border-color: rgba(45, 156, 143, 0.22);
  box-shadow: 0 22px 34px rgba(45, 156, 143, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(233, 255, 248, 0.92)),
    repeating-linear-gradient(
      -18deg,
      rgba(45, 156, 143, 0.04),
      rgba(45, 156, 143, 0.04) 16px,
      transparent 16px,
      transparent 32px
    );
}

.hint-text {
  margin: 0;
  text-align: center;
  font-size: 1.02rem;
  color: var(--text-soft);
}

.number-display {
  display: grid;
  place-items: center;
  min-height: 180px;
  margin-top: 10px;
  font-size: clamp(4.8rem, 12vw, 9rem);
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: 0.06em;
  text-shadow: 0 12px 24px rgba(207, 79, 29, 0.16);
}

.factor-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  margin: 0 auto 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.96rem;
  color: #fff;
  background: rgba(45, 156, 143, 0.9);
  box-shadow: 0 10px 24px rgba(45, 156, 143, 0.18);
}

.factor-hint[hidden] {
  display: flex;
  visibility: hidden;
}

.factor-hint span {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-deep);
  line-height: 1.1;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 0 0 1px rgba(207, 79, 29, 0.1);
}

.answer-area {
  display: block;
  min-height: 136px;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px dashed rgba(74, 47, 27, 0.16);
}

.answer-area[hidden] {
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.answer-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1.02rem;
  color: var(--text-soft);
}

.formula-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 10px;
  min-height: 76px;
}

.formula-item {
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(240, 109, 56, 0.18);
  box-shadow: 0 10px 20px rgba(113, 68, 25, 0.08);
  animation: rise-in 0.3s ease both;
}

.formula-primary {
  display: block;
  font-size: 1.18rem;
  text-align: center;
}

.formula-secondary {
  display: block;
  margin-top: 8px;
  font-size: 0.95rem;
  text-align: center;
  color: var(--text-soft);
}

.intro-panel {
  margin-top: 20px;
  padding: 22px 24px;
}

.intro-panel h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.intro-panel p {
  margin: 8px 0 0;
  line-height: 1.7;
  color: var(--text-soft);
}

.session-notice {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 18px;
  color: #fff;
  background: rgba(74, 47, 27, 0.92);
  box-shadow: 0 18px 40px rgba(74, 47, 27, 0.24);
  transform: translate(-50%, 12px);
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.session-notice.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1060px) {
  .controls-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .button-group {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100%, calc(100% - 16px));
    padding-top: 12px;
    padding-bottom: 20px;
  }

  .page-header {
    margin-bottom: 12px;
  }

  .page-title {
    font-size: 1.75rem;
    letter-spacing: 0.06em;
  }

  .controls-panel {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }

  .duration-field {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .field,
  .toggle-field {
    gap: 6px;
  }

  .field label {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .duration-field label {
    flex: 1;
  }

  .toggle-option {
    width: 100%;
    justify-content: flex-start;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 0.92rem;
  }

  .duration-control {
    height: 38px;
    width: 72px;
    flex: 0 0 auto;
    padding: 0 24px 0 10px;
    border-radius: 12px;
    font-size: 0.95rem;
    background-position:
      calc(100% - 14px) calc(50% - 2px),
      calc(100% - 9px) calc(50% - 2px);
  }

  .minutes-control {
    width: 84px;
  }

  .button-group {
    width: 100%;
    gap: 8px;
    margin-top: 4px;
  }

  button {
    flex: 1;
    min-width: 0;
    height: 38px;
    border-radius: 12px;
    font-size: 0.95rem;
  }

  .display-panel,
  .controls-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .display-panel {
    margin-top: 12px;
  }

  .intro-panel {
    padding: 16px;
    border-radius: 18px;
  }

  .practice-card {
    min-height: 280px;
    padding: 14px;
    border-radius: 18px;
  }

  .status-bar {
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
  }

  .status-pill {
    padding: 5px 10px;
    font-size: 0.82rem;
  }

  .hint-text {
    font-size: 0.94rem;
  }

  .number-display {
    min-height: 128px;
    margin-top: 6px;
    font-size: clamp(3.4rem, 18vw, 5.6rem);
  }

  .factor-hint {
    margin-bottom: 4px;
    padding: 6px 12px;
    font-size: 0.86rem;
  }

  .factor-hint[hidden] {
    display: flex;
  }

  .factor-hint span {
    font-size: 1.22rem;
  }

  .answer-area {
    min-height: 132px;
    margin-top: 8px;
    padding-top: 12px;
  }

  .answer-area[hidden] {
    display: block;
  }

  .answer-title {
    margin-bottom: 8px;
    font-size: 0.94rem;
  }

  .formula-list {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(38px, auto);
    gap: 6px;
    min-height: 82px;
  }

  .formula-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 8px 10px;
    text-align: center;
  }

  .formula-primary {
    font-size: clamp(0.92rem, 3.8vw, 1rem);
    line-height: 1.25;
    white-space: nowrap;
  }

  .session-notice {
    bottom: 16px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
  }
}
