:root {
  --paper: #fbf7f1;
  --surface: #ffffff;
  --ink: #2e2a26;
  --muted: #7a7065;
  --line: #ebe3d7;
  --matcha: #5e7a4f;
  --matcha-deep: #45603a;
  --matcha-soft: #e7eedf;
  --shortage: #c98a3a;
  --stagnation: #4e8a8f;
  --radius: 24px;
  --shadow: 0 1px 2px rgba(46, 42, 38, 0.04), 0 12px 32px rgba(46, 42, 38, 0.07);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo",
    sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(226, 163, 59, 0.1), transparent 34%),
    radial-gradient(circle at 92% 20%, rgba(78, 154, 166, 0.1), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(224, 138, 138, 0.08), transparent 40%),
    var(--paper);
  background-attachment: fixed;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sp {
  display: none;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(960px, 100% - 32px);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 0 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  color: var(--ink);
}

.brand {
  gap: 10px;
}

.brand__logo {
  height: 46px;
  width: auto;
  display: block;
}

.brand__text {
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.18em;
  color: var(--matcha-deep);
}

.topbar__reset {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

main {
  flex: 1;
  width: min(960px, 100% - 32px);
  margin: 0 auto;
}

.screen {
  padding: 8px 0 32px;
  animation: fade 0.35s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--matcha);
  color: #fff;
  box-shadow: 0 8px 20px rgba(94, 122, 79, 0.3);
}

.btn--accent {
  background: linear-gradient(135deg, #c98a3a, #b5652f);
  box-shadow: 0 8px 20px rgba(181, 101, 47, 0.3);
}

.btn--ghost {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn--xl {
  min-height: 68px;
  padding: 0 44px;
  font-size: 1.2rem;
}

.btn:focus-visible,
.item:focus-visible,
.topbar__reset:focus-visible {
  outline: 3px solid rgba(94, 122, 79, 0.45);
  outline-offset: 3px;
}

/* ---------- Start ---------- */
.screen--start:not([hidden]) {
  min-height: calc(100dvh - 150px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.start-hero {
  text-align: center;
  padding: 24px 0 8px;
}

.kbs {
  display: inline-flex;
  margin-bottom: 18px;
}

.kbs__dot {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 -7px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 1.5rem;
  color: #fff;
  mix-blend-mode: multiply;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.kbs__dot--ki {
  background: #e2a33b;
}
.kbs__dot--ketsu {
  background: #e08a8a;
}
.kbs__dot--sui {
  background: #4e9aa6;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--matcha);
}

.start-title {
  margin: 0 0 12px;
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.lead {
  max-width: 30em;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 1rem;
}

.start-meta {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.type-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 36px 0 24px;
}

.type-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 6px 12px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.type-chip .illust {
  width: 72px;
  height: 72px;
}

.type-chip strong {
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ink);
}

.type-chip span {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.qr-card {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 440px;
  margin: 8px auto 0;
  padding: 16px 22px 16px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.qr-card__code {
  flex: 0 0 auto;
  width: 120px;
  height: 120px;
}

.qr-card__code svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-card__title {
  margin: 0;
  font-weight: 900;
  font-size: 1.1rem;
}

.qr-card__text {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Progress ---------- */
.progress {
  margin: 6px 0 16px;
}

.progress__dots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.progress__dot {
  position: relative;
  display: block;
  padding-top: 12px;
  text-align: center;
  font-size: 0.75rem;
  color: #b4aa9e;
}

.progress__dot::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  border-radius: 6px;
  background: var(--line);
}

.progress__dot.done::before {
  background: var(--c);
  opacity: 0.45;
}

.progress__dot.current::before {
  background: var(--c);
}

.progress__dot.current {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Step card ---------- */
.step-card {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fade 0.3s ease;
}

.step-card__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg);
}

.step-card__illust .illust {
  width: 88px;
  height: 88px;
  display: block;
}

.step-card__illust path:first-child {
  fill: #fff;
}

.badge {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.badge--shortage {
  background: var(--shortage);
}
.badge--stagnation {
  background: var(--stagnation);
}

.step-card__name {
  margin: 4px 0 0;
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.06em;
}

.step-card__name small {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.step-card__nick {
  margin: 2px 0 0;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.75;
}

.step-card__count {
  min-width: 76px;
  padding: 8px 12px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
  font-weight: 900;
  font-size: 2rem;
  line-height: 1;
  color: var(--t, var(--c));
}

.step-card__count small {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.items {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  gap: 8px;
}

@media (min-width: 720px) {
  .items {
    grid-template-columns: 1fr 1fr;
    padding: 18px;
    gap: 10px;
  }
}

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: left;
  font-size: 1.02rem;
  line-height: 1.45;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.item__box {
  flex: 0 0 auto;
  position: relative;
  width: 28px;
  height: 28px;
  border: 2px solid #cfc5b8;
  border-radius: 9px;
  background: #fff;
  transition: 0.15s ease;
}

.item.is-on {
  border-color: var(--c);
  background: var(--bg);
}

.item.is-on .item__box {
  border-color: var(--c);
  background: var(--c);
}

.item.is-on .item__box::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.step-nav {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 0 calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(180deg, rgba(251, 247, 241, 0), var(--paper) 35%);
}

/* ---------- Result ---------- */
.result-hero {
  position: relative;
  padding: 28px 22px 26px;
  border-radius: 32px;
  background: linear-gradient(180deg, var(--bg, var(--matcha-soft)), #fff 70%);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-hero__pre {
  margin: 0;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.result-hero__illust .illust {
  width: 140px;
  height: 140px;
  margin: 6px auto 0;
  display: block;
}

.result-hero__illust path:first-child {
  fill: #fff;
}

.result-hero__title {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 900;
  line-height: 1.35;
}

.result-hero__type {
  font-size: 1.6em;
  color: var(--t, var(--c));
  letter-spacing: 0.06em;
  margin-right: 0.1em;
}

.result-hero__nick {
  margin: 4px 0 0;
  font-weight: 700;
}

.result-hero__text {
  max-width: 34em;
  margin: 12px auto 20px;
  text-align: left;
  color: #4d463f;
}

.result-hero--balanced {
  background: linear-gradient(180deg, var(--matcha-soft), #fff 70%);
}

.result-hero--balanced .result-hero__title {
  margin-top: 10px;
  color: var(--matcha-deep);
}

.result-hero--balanced .result-hero__text {
  text-align: center;
  margin-bottom: 0;
}

.result-hero__cta {
  margin: 14px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--matcha-deep);
  text-wrap: balance;
}

.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--t, var(--matcha));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: 0.15em;
}

/* Tea card */
.tea {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 12px 12px;
  border-radius: 22px;
  background: #fff;
  border: 2px solid var(--line);
  text-align: left;
}

.tea--main {
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 24px 16px 16px;
  border: 3px solid var(--c);
  box-shadow: 0 10px 28px rgba(46, 42, 38, 0.1);
}

.tea__illust .illust {
  display: block;
  width: 72px;
  height: 72px;
}

.tea--main .tea__illust .illust {
  width: 104px;
  height: 104px;
}

.tea__label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.tea__name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.3;
  color: var(--t, var(--c));
  letter-spacing: 0.06em;
}

.tea--main .tea__name {
  font-size: 2.2rem;
}

.tea__catch {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

.result-block {
  margin-top: 28px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 900;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.also {
  display: grid;
  gap: 14px;
}

.also-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.also-card__illust .illust {
  width: 76px;
  height: 76px;
  display: block;
}

.also-card__type {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--t, var(--c));
}

.also-card__type small {
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 700;
}

.also-card__desc {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #4d463f;
}

.also-card .tea {
  grid-column: 1 / -1;
  margin-top: 10px;
  background: var(--bg);
  border-color: transparent;
}

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

.lineup__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.lineup__item .illust {
  width: 72px;
  height: 72px;
}

.lineup__item strong {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--t, var(--c));
}

.lineup__item span {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Balance */
.balance {
  display: grid;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  .balance {
    grid-template-columns: 1.1fr 1fr;
    padding: 24px 28px;
  }
}

.radar svg {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.radar__label {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  fill: var(--ink);
}

.radar__num {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 900;
}

.score-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.score-list li {
  display: grid;
  grid-template-columns: 3em 1fr 2em;
  align-items: center;
  gap: 10px;
}

.score-list__name {
  font-weight: 700;
}

.score-list__bar {
  height: 12px;
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}

.score-list__bar span {
  display: block;
  height: 100%;
  border-radius: 12px;
  background: var(--c);
}

.score-list__num {
  text-align: right;
  font-weight: 900;
  color: var(--t, var(--c));
}

.disclaimer {
  margin: 20px 4px 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

body:not(.is-kiosk) #next-person-btn {
  display: none;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

/* ---------- Idle dialog ---------- */
.idle {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(46, 42, 38, 0.35);
  backdrop-filter: blur(4px);
}

.idle__card {
  width: min(360px, 100%);
  padding: 28px 24px;
  border-radius: var(--radius);
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow);
}

.idle__title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
}

.idle__text {
  margin: 6px 0 20px;
  color: var(--muted);
}

/* ---------- Phone ---------- */
@media (max-width: 719px) {
  .sp {
    display: inline;
  }

  .type-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .step-card__head {
    grid-template-columns: auto 1fr;
    padding: 16px;
  }

  .step-card__illust .illust {
    width: 68px;
    height: 68px;
  }

  .step-card__name {
    font-size: 1.5rem;
  }

  .step-card__count {
    position: absolute;
    right: 16px;
    margin-top: -4px;
    min-width: 0;
    font-size: 1.5rem;
  }

  .step-card {
    position: relative;
  }

  .step-card__head {
    position: relative;
  }

  .step-card__count {
    top: 16px;
  }

  .tea--main .tea__name {
    font-size: 1.8rem;
  }

  .tea--main .tea__illust .illust {
    width: 80px;
    height: 80px;
  }

  .also-card__illust .illust {
    width: 60px;
    height: 60px;
  }

  .progress__dot {
    font-size: 0.68rem;
  }
}

@media (max-width: 380px) {
  .lineup {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Furigana ---------- */
ruby {
  ruby-position: over;
}

rt {
  font-size: 0.42em;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.result-hero__type rt,
.tea--main .tea__name rt {
  font-size: 0.32em;
}

.score-list__name rt,
.type-chip rt {
  font-size: 0.55em;
}

.radar__rt {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  fill: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.tea__catch {
  text-wrap: pretty;
}
