:root {
  --bg-a: #f4eee1;
  --bg-b: #eae2cf;
  --ink: #2b251d;
  --muted: #6e6454;
  --line: rgba(142, 115, 67, 0.24);
  --paper: rgba(234, 221, 202, 0.94);
  --paper-strong: rgba(228, 218, 196, 0.98);
  --accent: #8e7343;
  --accent-dark: #765e35;
  --accent-soft: rgba(142, 115, 67, 0.12);
  --purple: #735d88;
  --shadow: rgba(43, 37, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -18%, rgba(142, 115, 67, 0.12), transparent 48%),
    radial-gradient(circle at 8% 12%, rgba(115, 93, 136, 0.08), transparent 30%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", "Segoe UI", sans-serif;
  padding: 8px 12px;
}

button,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  width: min(1240px, 100%);
  height: calc(100vh - 16px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-height: 0;
}

.topbar,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 54px var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  min-height: 64px;
  border-radius: 999px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--accent);
  border: 1px solid var(--line);
  background: var(--accent-soft);
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.brand small,
.top-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.top-note {
  margin: 0;
  white-space: nowrap;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(430px, 1fr);
  gap: 12px;
  align-items: start;
}

.left-column {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
}

.panel {
  position: relative;
  min-height: 0;
  border-radius: 28px;
  padding: clamp(18px, 2.2vw, 28px);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(142, 115, 67, 0.12);
  border-radius: 20px;
  pointer-events: none;
}

.onepage {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
}

.intro-content {
  width: 100%;
  position: relative;
  z-index: 1;
}

.kicker {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
  margin: 8px 0 8px;
}

.onepage p {
  color: var(--muted);
  font-size: clamp(0.98rem, 1.2vw, 1.08rem);
  line-height: 1.55;
  margin: 0;
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 5px 0 0;
  font-size: clamp(1.55rem, 2.5vw, 2.15rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.duration {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.breath-panel {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-rows: auto minmax(150px, 1fr) auto auto auto;
  align-items: center;
}

.breath-orb {
  position: relative;
  z-index: 1;
  width: min(270px, 64%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 999px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.44), transparent 60%),
    linear-gradient(145deg, var(--paper-strong), var(--paper));
  box-shadow:
    inset 0 0 30px rgba(255, 255, 255, 0.58),
    0 18px 44px var(--shadow);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 24px;
  transition: transform 0.7s ease, box-shadow 0.7s ease;
}

.breath-orb.is-inhale,
.breath-orb.is-hold {
  transform: scale(1.055);
  box-shadow:
    inset 0 0 42px rgba(255, 255, 255, 0.78),
    0 24px 54px rgba(142, 115, 67, 0.15);
}

.breath-orb.is-exhale {
  transform: scale(0.92);
  box-shadow:
    inset 0 0 22px rgba(255, 255, 255, 0.38),
    0 12px 32px var(--shadow);
}

.phase {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 950;
}

.seconds {
  font-size: clamp(4.8rem, 9vw, 7.3rem);
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: -0.07em;
}

.phase-en {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.timeline {
  position: relative;
  z-index: 1;
  height: 9px;
  background: rgba(142, 115, 67, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 12px;
}

.timeline-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: inherit;
  transition: width 0.2s linear;
}

.controls,
.chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button,
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.38);
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.button:hover:not(:disabled),
.chip:hover {
  background: rgba(142, 115, 67, 0.08);
  border-color: rgba(142, 115, 67, 0.42);
}

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

.button:active:not(:disabled),
.chip:active {
  transform: scale(0.98);
}

.button-primary {
  color: var(--bg-a);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
}

.chips {
  margin-top: 10px;
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: rgba(142, 115, 67, 0.38);
}

.card-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.psy-card {
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(142, 115, 67, 0.2);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.2);
  padding: clamp(14px, 1.7vw, 20px);
  overflow: hidden;
}

.psy-card.is-dealing {
  animation: deal 0.58s cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes deal {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    filter: blur(4px);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#cardSymbol {
  font-size: 1.35rem;
  line-height: 1;
}

.psy-card h3 {
  font-size: clamp(1.35rem, 2.7vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
  margin: 12px 0 6px;
}

.card-title-en {
  color: var(--muted);
  font-size: clamp(0.92rem, 1.1vw, 1rem);
  line-height: 1.35;
  margin-bottom: 12px;
}

.card-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.card-grid section,
.source-box {
  border: 1px solid rgba(142, 115, 67, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.24);
  padding: 12px;
}

.label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.card-grid p,
.source-box p {
  color: var(--muted);
  font-size: clamp(0.82rem, 0.95vw, 0.94rem);
  line-height: 1.62;
  margin: 0;
}

.source-box {
  margin-top: 10px;
  flex: none;
}

.source-box summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 950;
}

.source-box p {
  margin-top: 8px;
}

.copy-button {
  align-self: flex-start;
  margin-top: 10px;
}

.footer {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
  padding: 0 8px;
}

@media (max-height: 820px) and (min-width: 921px) {
  body {
    padding: 8px;
  }

  .app {
    height: calc(100vh - 16px);
    gap: 6px;
  }

  .stage {
    gap: 10px;
  }

  .left-column {
    gap: 10px;
  }

  .topbar {
    min-height: 54px;
    padding: 7px 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand small,
  .top-note {
    font-size: 0.78rem;
  }

  .panel {
    padding: 16px;
  }

  .onepage {
    min-height: 104px;
  }

  h1 {
    font-size: clamp(2.2rem, 4.4vw, 4rem);
  }

  .onepage p {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .panel-head h2 {
    font-size: clamp(1.35rem, 2.2vw, 1.95rem);
  }

  .breath-orb {
    width: min(210px, 56%);
  }

  .seconds {
    font-size: clamp(4rem, 8vw, 6.4rem);
  }

  .button,
  .chip {
    padding: 8px 12px;
  }

  .psy-card h3 {
    font-size: clamp(1.18rem, 2.2vw, 1.9rem);
  }

  .card-grid p,
  .source-box p {
    font-size: 0.8rem;
    line-height: 1.48;
  }
}

/* Mobile-only changes */
@media (max-width: 920px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
    padding: 12px;
  }

  .app {
    height: auto;
    min-height: calc(100vh - 24px);
  }

  .topbar {
    border-radius: 24px;
    align-items: center;
  }

  .top-note {
    display: none;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .left-column {
    gap: 0;
    padding: clamp(18px, 5vw, 24px);
    border-radius: 28px;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: 0 18px 54px var(--shadow);
    backdrop-filter: blur(14px);
    position: relative;
    overflow: hidden;
  }

  .left-column::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(142, 115, 67, 0.12);
    border-radius: 20px;
    pointer-events: none;
  }

  .left-column > .panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .left-column > .panel::before {
    display: none;
  }

  .onepage {
    min-height: auto;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(142, 115, 67, 0.18);
    margin-bottom: 22px;
  }

  .breath-panel {
    aspect-ratio: auto;
    display: block;
  }

  .breath-orb {
    width: min(250px, 72vw);
    margin: 18px auto;
  }

  .card-panel {
    height: auto;
    display: block;
  }

  .psy-card {
    display: block;
    flex: none;
    min-height: auto;
    overflow: visible;
  }

  .psy-card h3 {
    font-size: clamp(1.8rem, 8vw, 2.35rem);
    line-height: 1.15;
  }

  .card-title-en {
    font-size: 1.05rem;
    line-height: 1.45;
  }

  .card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    overflow: visible;
    min-height: auto;
    padding-right: 0;
  }

  .card-grid section,
  .source-box {
    padding: 18px;
    border-radius: 20px;
  }

  .card-grid p,
  .source-box p {
    font-size: 1rem;
    line-height: 1.72;
  }

  .source-box {
    display: block;
    margin-top: 14px;
  }

  .copy-button {
    display: inline-flex;
    margin-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .breath-orb,
  .timeline-bar,
  .button,
  .chip,
  .psy-card {
    animation: none !important;
    transition: none !important;
  }
}
