:root {
  /* Colours follow tm.org: cream ground, plum ink, yellow action, dusty blue, warm orange and coral */
  --cream: #F9F7E9;
  --cream-deep: #EFEBD8;
  --white: #FFFFFF;
  --ink: #1C0D22;
  --ink-soft: #352040;
  --plum: #462850;
  --line: #E7DDC6;
  --outline: #907E96;

  --yellow: #F0C814;
  --yellow-btn: #F8D850;
  --yellow-soft: #FFE7AE;
  --blue: #A5C3D7;
  --blue-soft: #D2E6EB;
  --rose-soft: #E5D1D3;
  --peach-soft: #F6EDE5;
  --sage-soft: #CFE3D4;
  --amber: #F5AA0A;
  --orange: #F39542;
  --coral: #E75867;
  --green: #2F7D6B;

  --vata: #A5C3D7;
  --pitta: #F39542;
  --kapha: #2F7D6B;

  --sans: 'Bricolage Grotesque', 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --r-card: 28px;
  --r-tile: 22px;
  --ease: cubic-bezier(.2, .9, .25, 1);
  --press: cubic-bezier(.3, 1.6, .5, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--cream); color: var(--ink);
  font: 400 17px/1.5 var(--sans); overflow-x: hidden;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--sans); font-weight: 600; margin: 0; letter-spacing: -.02em; line-height: 1.1; }
h1 em, h2 em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -.01em; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px; max-width: 1120px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 42px; height: 38px; flex: none; }
.brand h1 { font-size: 26px; }
.brand h1 em { font-size: 29px; }
.brand-sub { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.tools { display: flex; gap: 2px; flex: none; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; border: 0; border-radius: 50%; color: var(--plum); transition: background .2s; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: var(--cream-deep); }
#btnSound .mute { display: inline; }
#btnSound .waves { display: none; }
#btnSound[aria-pressed='true'] .mute { display: none; }
#btnSound[aria-pressed='true'] .waves { display: inline; }

/* Layout */
.layout { max-width: 1120px; margin: 0 auto; padding: 4px 16px 24px; display: grid; gap: 28px; }
@media (min-width: 900px) {
  .layout { grid-template-columns: 400px 1fr; gap: 40px; align-items: start; }
  .col-left { position: sticky; top: 16px; }
}
.mode-banner {
  margin: 0 0 12px; padding: 4px 6px 4px 16px; border-radius: 16px; background: var(--yellow-soft);
  font-size: 15px; font-weight: 500; color: var(--ink); white-space: nowrap; display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.mode-banner button { background: none; border: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 0 10px; }

/* Patient */
.patient { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.band { position: relative; height: 92px; }
.band.vata { background: linear-gradient(150deg, #8FB4CE 0%, #A5C3D7 30%, #D2E6EB 70%, #F3EFD9 100%); }
.band.pitta { background: linear-gradient(150deg, #F39542 0%, #F5AA0A 35%, #F7D79A 75%, #FFE7AE 100%); }
.band.kapha { background: linear-gradient(150deg, #5FA08C 0%, #8DBF9F 35%, #CFE3D4 75%, #F3EFD9 100%); }
/* Film grain, as on the photo gradients of tm.org */
.band::after {
  content: ''; position: absolute; inset: 0; opacity: .35; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.season {
  position: absolute; z-index: 1; right: 14px; top: 14px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 8px; border-radius: 999px; background: var(--white); font-size: 14px; font-weight: 500; color: var(--ink);
}
.season svg { width: 18px; height: 18px; color: var(--plum); }
.patient-body { padding: 0 20px 20px; }
.portrait { width: 96px; height: 96px; margin-top: -48px; position: relative; z-index: 1; border-radius: 50%; border: 5px solid var(--white); overflow: hidden; }
.portrait.vata { background: var(--blue-soft); } .portrait.pitta { background: var(--yellow-soft); } .portrait.kapha { background: var(--sage-soft); }
.portrait svg { display: block; width: 100%; height: 100%; }
.patient h2 { font-size: 30px; margin-top: 8px; }
.patient-meta { margin: 2px 0 0; font-size: 16px; color: var(--ink-soft); }
.patient-story { margin: 12px 0 0; }
.symptoms { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.symptoms li { position: relative; padding: 9px 12px 9px 36px; font-size: 16px; line-height: 1.35; background: var(--cream); border-radius: 14px; }
.symptoms li::before { content: ''; position: absolute; left: 13px; top: 15px; width: 11px; height: 11px; border-radius: 50%; background: var(--coral); }

/* Balance meter */
.meter { position: relative; margin-top: 14px; padding: 18px 18px 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.meter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.meter-head h2 { font-size: 22px; }
.meter-head h2 em { font-size: 24px; }
.tries { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.dots { display: flex; gap: 5px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--plum); border: 2px solid var(--plum); transition: background .4s; }
.dots i.out { background: var(--white); }

.rails { display: grid; gap: 26px; }
.rail { display: grid; grid-template-columns: 108px 1fr 30px; align-items: center; gap: 8px; }
.rail-label { display: flex; align-items: center; gap: 8px; }
.chip { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.chip svg { width: 17px; height: 17px; }
.chip.v { background: var(--vata); } .chip.p { background: var(--pitta); } .chip.k { background: var(--kapha); color: var(--white); }
.rail-label b { display: block; font: 600 16px/1.1 var(--sans); }
.rail-label small { display: block; font-size: 14px; color: var(--ink-soft); line-height: 1.2; }
.rail-value { font: 600 17px/1 var(--sans); text-align: right; font-variant-numeric: tabular-nums; }
.track { position: relative; height: 36px; }
.track::before { content: ''; position: absolute; left: 0; right: 0; top: 12px; height: 12px; border-radius: 6px; background: var(--cream-deep); }
.bead-lane { position: absolute; inset: 0 17px; }
.zone { position: absolute; top: 3px; bottom: 3px; border-radius: 15px; background: var(--yellow-soft); border: 2px solid var(--yellow); transition: background .5s; }
.tick { position: absolute; top: 16px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--outline); }
.bead {
  position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink); border: 3px solid var(--white); box-shadow: 0 0 0 2px var(--plum);
  transition: left .7s var(--ease);
}
.bead svg { width: 16px; height: 16px; }
.bead.v { background: var(--vata); } .bead.p { background: var(--pitta); } .bead.k { background: var(--kapha); color: var(--white); }
.ghost { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px dashed var(--plum); background: var(--white); }
.delta {
  position: absolute; top: -21px; transform: translateX(-50%); padding: 0 7px; border-radius: 8px;
  background: var(--ink); color: var(--cream); font: 600 14px/1.5 var(--sans); animation: delta 1.1s var(--ease) forwards; pointer-events: none; z-index: 2;
}
@keyframes delta { 0% { opacity: 0; transform: translate(-50%, 6px); } 20% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -8px); } }
.meter-status { min-height: 1.5em; margin: 16px 0 0; font-size: 16px; text-align: center; }
.meter.solved .zone { background: var(--yellow); }
.confetti { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; pointer-events: none; animation: confetti 1.5s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes confetti { from { opacity: 1; transform: translate(0, 0) rotate(0); } 70% { opacity: 1; } to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); } }

/* Hand: card tiles */
.hand-head h2 { font-size: 28px; }
.hand-head h2 em { font-size: 31px; }
.hand-head p { margin: 6px 0 14px; font-size: 16px; color: var(--ink-soft); }
.hand { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .hand { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; } }
.card {
  position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; padding: 8px 8px 12px; text-align: left;
  background: var(--white); border: 2px solid var(--line); border-radius: var(--r-tile);
  transition: transform .25s var(--press), box-shadow .25s var(--press), border-color .2s;
}
.card:hover { border-color: var(--outline); }
.card[aria-pressed='true'] { border-color: var(--plum); transform: translateY(-4px); box-shadow: 0 5px 0 var(--plum); }
.card:disabled { cursor: default; }
.art { display: grid; place-items: center; height: 104px; border-radius: 15px; }
.art img { width: 84px; height: 84px; }
.art.food, .slot.food, .thumb.food { background: var(--peach-soft); }
.art.routine, .slot.routine, .thumb.routine { background: var(--blue-soft); }
.art.activity, .slot.activity, .thumb.activity { background: var(--rose-soft); }
.card-text { display: block; padding: 10px 4px 0; }
.card-kind { display: flex; align-items: center; gap: 5px; font-size: 14px; color: var(--ink-soft); }
.card-kind svg { width: 15px; height: 15px; }
.card-name { display: block; font: 600 17px/1.2 var(--sans); letter-spacing: -.01em; margin: 3px 0 8px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 14px; line-height: 1.35; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--outline); }
.tag.taste { background: var(--yellow-soft); border-color: var(--yellow-soft); font-weight: 500; }
.seal {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; display: none; place-items: center;
  background: var(--yellow-btn); border: 2px solid var(--plum); font: 700 15px/1 var(--sans); color: var(--ink);
}
.card[aria-pressed='true'] .seal { display: grid; animation: pop .3s var(--press); }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }

.disclaimer { margin: 22px 0 0; font-size: 14px; color: var(--ink-soft); text-align: center; }

/* Bottom tray, reachable with one thumb */
.tray {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--cream); border-top: 1px solid var(--line);
}
.slots { display: flex; gap: 8px; }
.slot { width: 52px; height: 52px; border-radius: 16px; padding: 0; border: 2px dashed var(--outline); background: transparent; display: grid; place-items: center; }
.slot.filled { border: 2px solid var(--plum); animation: pop .3s var(--press); }
.slot img { width: 40px; height: 40px; }
.primary {
  min-width: 136px; height: 54px; padding: 0 26px; border-radius: 27px; border: 2px solid var(--ink);
  font: 600 18px/1 var(--sans); color: var(--cream); background: var(--ink); box-shadow: 0 5px 0 var(--yellow);
  transition: transform .12s, box-shadow .12s;
}
.primary:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--yellow); }
.primary:disabled { background: var(--white); color: var(--ink); border-color: var(--outline); box-shadow: none; cursor: default; }
.secondary { min-height: 54px; padding: 0 22px; border-radius: 27px; border: 2px solid var(--plum); background: var(--white); color: var(--ink); font: 600 17px/1 var(--sans); }

.flyer { position: fixed; z-index: 20; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; pointer-events: none; border: 2px solid var(--plum); transition: transform .55s var(--ease), opacity .55s; }
.flyer img { width: 50px; height: 50px; }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(28, 13, 34, .55); animation: fade .25s; }
.sheet {
  position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--cream);
  border-radius: 32px 32px 0 0; padding: 26px 18px calc(28px + env(safe-area-inset-bottom)); animation: rise .4s var(--ease);
}
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 640px; transform: translateX(-50%); bottom: 24px; border-radius: 32px; padding: 30px 28px; animation: fade .3s; } }
.sheet:focus { outline: none; }
.sheet-close { position: absolute; top: 14px; right: 12px; }
@keyframes rise { from { transform: translateY(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet h2 { font-size: 34px; padding-right: 44px; }
.sheet h2 em { font-size: 38px; }
.sheet h3 { font-size: 21px; margin: 26px 0 12px; }
.sheet .lead { margin: 8px 0 0; }
.sheet ul { padding-left: 22px; }
.sheet li { margin-bottom: 6px; }
.sheet a { color: var(--ink); text-underline-offset: 3px; }
.stars { display: flex; gap: 8px; margin: 14px 0 6px; }
.stars i { width: 30px; height: 30px; border-radius: 50%; border: 2px dashed var(--outline); }
.stars i.on { background: var(--yellow); border: 2px solid var(--plum); }
.levels-line { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); font: 500 15px/1.4 var(--sans); }
.pill .chip { width: 24px; height: 24px; }
.pill .chip svg { width: 14px; height: 14px; }
.explain { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 10px; }
.explain li { display: grid; grid-template-columns: 60px 1fr; gap: 14px; padding: 12px; margin: 0; border-radius: 20px; background: var(--white); border: 1px solid var(--line); }
.thumb { width: 60px; height: 60px; border-radius: 15px; display: grid; place-items: center; }
.thumb img { width: 48px; height: 48px; }
.explain b { font: 600 18px/1.2 var(--sans); display: block; letter-spacing: -.01em; }
.explain p { margin: 6px 0 0; font-size: 16px; }
.explain .src { font-size: 14px; color: var(--ink-soft); }
.explain .src a { color: var(--ink-soft); }
.effects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.effect { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px 2px 3px; border-radius: 999px; font: 500 14px/1.4 var(--sans); background: var(--cream); }
.effect .chip { width: 22px; height: 22px; }
.effect .chip svg { width: 13px; height: 13px; }
.effect .arrow { width: 10px; height: 10px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; padding-bottom: 4px; }
.small-note { margin: 18px 0 0; font-size: 14px; color: var(--ink-soft); }
.dosha-list { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.dosha-list li { display: flex; align-items: center; gap: 10px; margin: 0; }

.puzzle-grid { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 18px; }
.puzzle-grid li { margin: 0; }
.puzzle-grid button { width: 100%; min-height: 104px; border-radius: 20px; border: 2px solid var(--line); background: var(--white); display: grid; place-items: center; gap: 2px; padding: 10px 6px; }
.puzzle-grid button:not(:disabled):hover { border-color: var(--plum); }
.puzzle-grid button:disabled { background: var(--cream-deep); cursor: default; }
.puzzle-grid .num { font: 700 28px/1 var(--sans); }
.puzzle-grid .who { font-size: 14px; color: var(--ink-soft); }
.mini-stars { display: flex; gap: 3px; height: 10px; }
.mini-stars i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--plum); }
.mini-stars i.on { background: var(--yellow); }

.toast { position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; width: max-content; max-width: calc(100vw - 32px); background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 16px; font-size: 16px; animation: rise .3s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
