:root {
  color-scheme: light;
  --ink: #20202a;
  --muted: #626070;
  --line: rgba(32, 32, 42, 0.11);
  --paper: rgba(255, 255, 255, 0.88);
  --white: #ffffff;
  --green: #1fae7a;
  --green-dark: #137b58;
  --coral: #f06f5b;
  --amber: #f4bf45;
  --blue: #4f8ee8;
  --violet: #7a66d9;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(79, 142, 232, 0.18), transparent 36%),
    linear-gradient(225deg, rgba(240, 111, 91, 0.18), transparent 38%),
    #f6f4ec;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 340px);
  gap: 16px;
  align-items: center;
}

.workspace,
.side-panel {
  display: grid;
  gap: 14px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 9px;
  font-size: 0.95rem;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.game-link,
.section-head button {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-weight: 850;
}

.picker,
.action-card,
.stats,
.favorites {
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 42px rgba(32, 32, 42, 0.11);
  backdrop-filter: blur(10px);
}

.picker {
  padding: 15px;
  display: grid;
  gap: 14px;
}

.choice-group h2,
.stats h2,
.favorites h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.choice-group[data-group="energy"] .segmented {
  grid-template-columns: repeat(3, 1fr);
}

.kind-grid {
  grid-template-columns: repeat(3, 1fr);
}

.segmented button {
  min-height: 42px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--white);
  font-size: 0.9rem;
  font-weight: 850;
}

.segmented button.active {
  color: #ffffff;
  border-color: transparent;
  background: var(--green);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13);
}

.action-card {
  min-height: 390px;
  padding: clamp(18px, 4vw, 34px);
  display: grid;
  align-content: center;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.card-head span {
  padding: 7px 10px;
  border-radius: 8px;
  background: #eff8f2;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

#actionMeta {
  background: #fff5db;
  color: #8a6320;
}

#actionTitle {
  margin: 0 0 12px;
  font-size: clamp(1.65rem, 4.4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

#actionWhy {
  max-width: 62ch;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.62;
}

.starter {
  margin-bottom: 20px;
  padding: 13px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.starter span {
  display: block;
  margin-bottom: 4px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 950;
}

.starter strong {
  line-height: 1.45;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 9px;
}

.actions button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
}

.primary {
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 5px 0 var(--green-dark);
}

.secondary {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.feedback {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--green-dark);
  font-weight: 800;
}

.stats,
.favorites {
  padding: 15px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-grid div {
  padding: 12px 10px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  text-align: center;
}

.stat-grid span {
  display: block;
  font-size: 1.55rem;
  font-weight: 950;
}

.stat-grid small {
  color: var(--muted);
  font-weight: 850;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2 {
  margin: 0;
}

.history-list,
.favorite-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li,
.favorite-list li {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
}

.history-list strong,
.favorite-list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 16px, 560px);
    grid-template-columns: 1fr;
    align-items: start;
    padding: max(12px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: start;
  }

  .top-links {
    justify-content: flex-start;
  }

  .game-link {
    min-width: 84px;
    text-align: center;
  }

  .segmented,
  .choice-group[data-group="energy"] .segmented,
  .kind-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-card {
    min-height: auto;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: calc(100vw - 12px);
  }

  h1 {
    font-size: 2.3rem;
  }

  .picker,
  .action-card,
  .stats,
  .favorites {
    padding: 12px;
  }

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

  #actionTitle {
    font-size: 1.55rem;
  }
}
