:root {
  --bg: #fff8ec;
  --panel: #fffdf8;
  --paper: #fffaf1;
  --ink: #3b302b;
  --muted: #8e7c70;
  --line: #dfcfbc;
  --accent: #e97883;
  --mint: #a7d7b2;
  --blue: #a8cde3;
  --yellow: #f8cb63;
  --coral: #ed7e78;
  --purple: #aa9bd8;
  --shadow: #d8c5b3;
}
[data-theme="dark"] {
  --bg: #111a22;
  --panel: #1b2a32;
  --paper: #17242c;
  --ink: #fff1d4;
  --muted: #a8b5ae;
  --line: #40545a;
  --accent: #ff8f9b;
  --mint: #8dcca7;
  --blue: #77b7d3;
  --yellow: #f2ca62;
  --coral: #ed837c;
  --purple: #aa9bd8;
  --shadow: #081116;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 12px ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif; }
body { display: flex; justify-content: center; }
button, a { -webkit-tap-highlight-color: transparent; }
.page { width: min(900px, 100%); padding: 15px 14px calc(22px + env(safe-area-inset-bottom)); }
.topbar { min-height: 60px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; border-bottom: 2px dashed var(--line); margin-bottom: 12px; }
.back-link, .topbar > button { min-height: 44px; display: flex; align-items: center; color: var(--muted); font: 900 10px inherit; letter-spacing: .08em; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 8px 0; }
.topbar > button { justify-content: flex-end; }
.back-link:hover, .back-link:focus-visible, .topbar > button:hover, .topbar > button:focus-visible { color: var(--accent); outline: none; }
.brand { min-width: 0; text-align: center; }
.brand h1 { margin: 0; color: var(--ink); font-size: clamp(18px, 4vw, 27px); font-weight: 950; letter-spacing: .08em; line-height: 1; white-space: nowrap; transform: rotate(-1deg); }
.brand span { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .12em; white-space: nowrap; }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; width: min(100%, 820px); margin: 0 auto 10px; }
.stat { position: relative; overflow: hidden; min-width: 0; padding: 8px 10px 9px; border: 2px solid var(--ink); border-radius: 12px 10px 14px 9px; background: var(--panel); box-shadow: 2px 3px 0 var(--shadow); }
.stat::after { content: ""; position: absolute; right: -12px; bottom: -18px; width: 35px; height: 35px; border: 2px solid currentColor; border-radius: 50%; opacity: .2; }
.stat span { display: block; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.stat b { display: block; margin-top: 3px; color: var(--ink); font-size: clamp(12px, 3vw, 17px); line-height: 1; letter-spacing: .04em; }
.stat-score { color: var(--coral); }
.stat-best { color: var(--purple); }
.stat-energy { color: #d59b16; }
.stat-fruit { color: var(--accent); }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 215px; gap: 12px; align-items: start; width: min(100%, 820px); margin: 0 auto; }
.arena { position: relative; min-width: 0; padding: 5px; border: 3px solid var(--ink); border-radius: 22px 18px 25px 17px; background: var(--paper); box-shadow: 7px 8px 0 var(--shadow); transform: rotate(.15deg); }
.arena canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 14px 12px 18px 13px; background: var(--paper); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.overlay { position: absolute; inset: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; padding: 24px; border-radius: 14px 12px 18px 13px; background: color-mix(in srgb, var(--paper) 92%, transparent); text-align: center; }
.overlay.hidden { display: none; }
.unlock-toast { position: absolute; z-index: 3; top: 18px; left: 50%; max-width: calc(100% - 34px); padding: 8px 12px; border: 2px solid var(--ink); border-radius: 10px 8px 11px 7px; background: var(--yellow); color: var(--ink); box-shadow: 2px 3px 0 var(--ink); font-size: 9px; font-weight: 950; letter-spacing: .08em; opacity: 0; pointer-events: none; transform: translate(-50%, -8px); transition: opacity .18s ease, transform .18s ease; white-space: nowrap; }
.unlock-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.overlay-mark { color: var(--accent); font-size: 40px; line-height: 1; transform: rotate(14deg); }
.overlay b { color: var(--ink); font-size: clamp(25px, 6vw, 40px); font-weight: 950; letter-spacing: .06em; line-height: 1; transform: rotate(-2deg); }
.overlay span { max-width: 300px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .1em; line-height: 1.5; }
.overlay button, .stir-button, .mobile-actions button { min-height: 46px; padding: 11px 17px; border: 2px solid var(--ink); border-radius: 13px 10px 15px 9px; background: var(--yellow); color: var(--ink); box-shadow: 3px 4px 0 var(--ink); cursor: pointer; font: 950 10px inherit; letter-spacing: .07em; }
.overlay button:hover, .overlay button:focus-visible, .stir-button:hover, .stir-button:focus-visible, .mobile-actions button:hover, .mobile-actions button:focus-visible { background: var(--mint); outline: none; transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--ink); }
.lab-panel { display: flex; flex-direction: column; gap: 10px; }
.mode-card, .next-card, .lab-readout { padding: 13px; border: 2px solid var(--ink); border-radius: 14px 11px 16px 10px; background: var(--panel); box-shadow: 3px 4px 0 var(--shadow); }
.eyebrow { display: block; color: var(--muted); font-size: 8px; font-weight: 950; letter-spacing: .12em; }
.mode-button { width: 100%; min-height: 40px; margin-top: 9px; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 2px solid var(--accent); border-radius: 9px; background: color-mix(in srgb, var(--accent) 15%, var(--panel)); color: var(--ink); cursor: pointer; font: 950 10px inherit; letter-spacing: .05em; }
.mode-button span { color: var(--accent); font-size: 8px; }
.mode-card p, .lab-readout p { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.next-fruit { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.next-fruit i { width: 22px; height: 22px; display: block; border: 2px solid var(--ink); border-radius: 50%; background: #8dbd6b; box-shadow: inset 5px -4px 0 #6b9a55; }
.next-fruit b { font-size: 12px; letter-spacing: .08em; }
.next-card small { display: block; margin-top: 9px; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.stir-button { display: flex; justify-content: space-between; align-items: center; background: var(--coral); }
.stir-button b { font-size: 9px; }
.lab-readout { flex: 1; min-height: 120px; }
.mobile-actions { display: none; }
.synthesis { width: min(100%, 820px); margin: 14px auto 0; padding: 11px 13px 12px; border: 2px solid var(--ink); border-radius: 14px 11px 16px 10px; background: var(--panel); box-shadow: 3px 4px 0 var(--shadow); }
.synthesis-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; color: var(--muted); font-size: 8px; font-weight: 950; letter-spacing: .1em; }
.synthesis-head small { text-align: right; font-size: 7px; letter-spacing: .05em; }
.route { display: flex; align-items: center; justify-content: flex-start; gap: 4px; margin-top: 10px; overflow-x: auto; overflow-y: hidden; padding: 0 2px 5px; scrollbar-width: thin; }
.route-item { position: relative; display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .05em; }
.route-item.locked { opacity: .28; filter: grayscale(.85); }
.route-item span { white-space: nowrap; }
.route-item:not(:last-child)::after { content: "→"; position: absolute; top: 8px; left: calc(100% + 1px); color: var(--accent); font-size: 13px; }
.route-fruit { position: relative; width: 28px; height: 28px; display: block; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 50%; background: #8dbd6b; box-shadow: inset 5px -4px 0 #6b9a55; }
.route-fruit::before, .route-fruit::after { content: ""; position: absolute; pointer-events: none; }
.route-fruit[data-shape="kiwi"] { background: radial-gradient(circle, #d3ec9b 0 37%, #82be68 39% 100%); }
.route-fruit[data-shape="kiwi"]::after { width: 3px; height: 3px; left: 8px; top: 9px; border-radius: 50%; background: #578f58; box-shadow: 8px 3px 0 #578f58, 3px 9px 0 #578f58, 11px 11px 0 #578f58; }
.route-fruit[data-shape="lemon"] { border-radius: 58% 42% 58% 42%; transform: rotate(-18deg) scale(.94, .78); background: linear-gradient(155deg, #fff4a8 0 20%, #f3d15f 22% 100%); box-shadow: inset 4px -4px 0 #d39b38; }
.route-fruit[data-shape="lemon"]::after { width: 18px; height: 2px; left: 3px; top: 12px; background: #fff4a8; transform: rotate(18deg); }
.route-fruit[data-shape="cherry"] { border: 0; border-radius: 0; background: radial-gradient(circle at 30% 67%, #f5a1a8 0 10%, #dc6274 12% 38%, transparent 40%), radial-gradient(circle at 70% 67%, #f5a1a8 0 10%, #dc6274 12% 38%, transparent 40%); box-shadow: none; }
.route-fruit[data-shape="cherry"]::before { width: 12px; height: 13px; left: 8px; top: 0; border-left: 2px solid #47794e; border-right: 2px solid #47794e; border-radius: 50%; transform: rotate(9deg); }
.route-fruit[data-shape="peach"] { border-radius: 48% 52% 50% 50% / 42% 42% 58% 58%; background: radial-gradient(circle at 34% 28%, #ffd0ab 0 13%, transparent 15%), #ef9d83; box-shadow: inset 5px -4px 0 #c76b65; }
.route-fruit[data-shape="peach"]::after { width: 10px; height: 15px; left: 8px; top: 8px; border-right: 2px solid #c76b65; border-radius: 50%; transform: rotate(28deg); }
.route-fruit[data-shape="orange"] { background: conic-gradient(from 15deg, #ffd477 0 9%, #f09a3e 10% 19%, #ffd477 20% 24%, #f09a3e 25% 44%, #ffd477 45% 49%, #f09a3e 50% 69%, #ffd477 70% 74%, #f09a3e 75% 100%); box-shadow: inset 5px -4px 0 #c66b29; }
.route-fruit[data-shape="pear"] { width: 25px; height: 29px; margin: 0 2px -1px; border-radius: 48% 48% 42% 42% / 38% 38% 64% 64%; background: radial-gradient(circle at 34% 28%, #eff5a8 0 12%, transparent 14%), #b4c95d; box-shadow: inset 5px -4px 0 #718d3f; }
.route-fruit[data-shape="pear"]::before { width: 3px; height: 7px; left: 11px; top: -5px; border-radius: 3px; background: #718d3f; transform: rotate(10deg); }
.route-fruit[data-shape="pineapple"] { border-radius: 42% 42% 48% 48% / 46% 46% 58% 58%; background: repeating-linear-gradient(45deg, transparent 0 4px, #b0792e 5px 6px), repeating-linear-gradient(-45deg, #fff0a0 0 5px, #e6b94f 6px 10px); box-shadow: inset 5px -4px 0 #b0792e; }
.route-fruit[data-shape="pineapple"]::before { width: 18px; height: 9px; left: 3px; top: -7px; border-radius: 70% 20% 70% 20%; background: #b0792e; transform: rotate(-4deg); clip-path: polygon(0 100%, 18% 0, 42% 78%, 58% 0, 77% 78%, 100% 12%, 88% 100%); }
.route-fruit[data-shape="melon"] { background: radial-gradient(circle at 35% 28%, #d8ee99 0 12%, transparent 14%), repeating-linear-gradient(75deg, #78b968 0 5px, #4e9055 6px 8px); box-shadow: inset 5px -4px 0 #4e9055; }
.route-fruit[data-shape="dragonfruit"] { background: radial-gradient(circle at 50% 50%, #f8c4d5 0 34%, #e56b8a 36% 100%); box-shadow: inset 5px -4px 0 #a94368; }
.route-fruit[data-shape="dragonfruit"]::after { width: 5px; height: 7px; left: 2px; top: 3px; border-radius: 80% 0 80% 0; background: #a94368; transform: rotate(-30deg); box-shadow: 17px 1px 0 #a94368, 9px 17px 0 #a94368; }
.route-fruit[data-shape="papaya"] { width: 23px; height: 29px; margin: 0 3px -1px; border-radius: 50% 50% 48% 48% / 42% 42% 58% 58%; background: radial-gradient(ellipse at center, #ffd28e 0 35%, #f19b55 37% 100%); box-shadow: inset 5px -4px 0 #c96b39; }
.route-fruit[data-shape="papaya"]::after { width: 3px; height: 4px; left: 10px; top: 10px; border-radius: 50%; background: #c96b39; box-shadow: -4px 3px 0 #c96b39, 4px 3px 0 #c96b39, 0 7px 0 #c96b39; }
.route-fruit[data-shape="watermelon"] { background: radial-gradient(circle at 38% 30%, #e1f3a1 0 12%, transparent 14%), repeating-linear-gradient(72deg, #5ca865 0 5px, #3c7d50 6px 8px); box-shadow: inset 5px -4px 0 #3c7d50; }
footer { margin-top: 12px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; line-height: 1.5; text-align: center; }
@media (max-width: 700px) {
  .page { padding: 10px 10px max(19px, env(safe-area-inset-bottom)); }
  .topbar { min-height: 54px; gap: 5px; }
  .brand h1 { font-size: 17px; }
  .brand span { font-size: 6px; letter-spacing: .08em; }
  .back-link, .topbar > button { font-size: 8px; }
  .hud { gap: 5px; }
  .stat { padding: 7px 6px 8px; border-width: 1.5px; box-shadow: 1px 2px 0 var(--shadow); }
  .stat span { font-size: 7px; }
  .stat b { font-size: 11px; }
  .workbench { display: block; }
  .arena { width: min(100%, 570px); margin: 0 auto; border-width: 2px; border-radius: 18px 16px 21px 15px; box-shadow: 5px 6px 0 var(--shadow); }
  .arena canvas, .overlay { border-radius: 11px 10px 14px 10px; }
  .overlay { inset: 4px; gap: 10px; }
  .overlay-mark { font-size: 31px; }
  .overlay b { font-size: 25px; }
  .overlay span { font-size: 8px; }
  .lab-panel { display: grid; grid-template-columns: 1fr 1fr; margin-top: 13px; gap: 8px; }
  .lab-panel .stir-button { display: none; }
  .mode-card, .next-card, .lab-readout { min-height: 0; padding: 10px; box-shadow: 2px 3px 0 var(--shadow); }
  .lab-readout { grid-column: 1 / -1; }
  .mode-card p, .lab-readout p { font-size: 9px; }
  .stir-button { min-height: 46px; padding: 9px 10px; box-shadow: 2px 3px 0 var(--ink); }
  .mobile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; margin-bottom: 58px; }
  .mobile-actions button { min-height: 50px; box-shadow: 2px 3px 0 var(--ink); }
  .synthesis { margin-top: 12px; padding: 10px; }
  .synthesis-head { display: block; }
  .synthesis-head small { display: block; margin-top: 5px; text-align: left; line-height: 1.4; }
  .route-fruit { width: 25px; height: 25px; }
  .route-item { font-size: 6px; }
  .route-item:not(:last-child)::after { top: 6px; font-size: 11px; }
  footer { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
