/* Pi & e explorers: one engine (digits/explorer.js), each constant is data
   (digits/constants.js). /pi and /e load this file with a ?v= content hash. */
:root { color-scheme: dark; --ink: #fff; --dim: #ffffffa8; --card: #ffffff12; --line: #ffffff24;
  --accent: #ffd23f; --accent2: #ff6fae; --bg1: #2b2470; --bg2: #0d0b2e; --hit: #ffd23f;
  --d0: #f1f1f1; --d1: #ff595e; --d2: #ff924c; --d3: #ffca3a; --d4: #c5ca30;
  --d5: #8ac926; --d6: #36d6c3; --d7: #43a6ff; --d8: #b083ff; --d9: #f15bb5; }
body[data-constant="e"] { --accent: #4dffc3; --accent2: #ff8a5b; --bg1: #0f4d57; --bg2: #06171c; --hit: #4dffc3; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { position: fixed; inset: 0; overflow: hidden; color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  background: radial-gradient(130% 100% at 50% 0%, var(--bg1), var(--bg2) 72%);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }

/* top bar */
.bar { position: fixed; top: 0; left: 0; right: 0; height: calc(76px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0 156px; display: flex; align-items: center; gap: 14px; z-index: 10;
  background: linear-gradient(#00000055, #00000000); }
.bar h1 { margin: 0; font-size: clamp(24px, 4vw, 36px); font-weight: 900; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.bar h1 .sym { color: var(--accent); font-family: "Times New Roman", Georgia, serif; font-style: italic; font-size: 1.15em; }
.swap { display: flex; background: #00000040; border-radius: 999px; padding: 5px; gap: 4px; flex: none; }
.swap a { display: grid; place-items: center; min-width: 64px; height: 54px; border-radius: 999px; text-decoration: none;
  color: var(--ink); font: italic 800 30px "Times New Roman", Georgia, serif; }
.swap a[aria-current] { background: var(--accent); color: #111; }
.kk-home { z-index: 11; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: #00000066; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; max-width: 150px; min-height: 64px; border-radius: 18px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 15px; font-weight: 800; color: var(--dim); }
.tabs button b { font-size: 28px; line-height: 1; }
.tabs button[aria-selected="true"] { background: #ffffff1f; color: var(--ink); box-shadow: inset 0 -4px 0 var(--accent); }

/* page */
main { position: absolute; left: 0; right: 0; top: calc(76px + env(safe-area-inset-top)); bottom: calc(82px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 28px; }
section[hidden] { display: none !important; }
.wrap { max-width: 980px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 16px 18px; margin: 12px 0; }
h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 900; }
.hint { color: var(--dim); font-size: 17px; margin: 4px 0 10px; line-height: 1.35; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { min-height: 56px; padding: 0 18px; border-radius: 999px; background: #ffffff18; font-size: 19px; font-weight: 800; border: 2px solid transparent; }
.chip[aria-pressed="true"] { background: var(--accent); color: #111; }
.chip.small { min-height: 48px; font-size: 17px; padding: 0 14px; }
.btn { min-height: 64px; padding: 0 24px; border-radius: 20px; background: var(--accent); color: #111; font-size: 21px; font-weight: 900; }
.btn.ghost { background: #ffffff1c; color: var(--ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* keypad */
.entry { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 2px; flex-wrap: wrap;
  font-size: clamp(30px, 5vw, 44px); font-weight: 900; letter-spacing: .04em; background: #00000040; border-radius: 20px; padding: 6px 14px; word-break: break-all; }
.entry .ph { color: var(--dim); font-size: 22px; letter-spacing: 0; font-weight: 700; }
.pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; }
.pad button { min-height: 66px; border-radius: 18px; background: #ffffff1a; font-size: 30px; font-weight: 900; }
.pad button:active { transform: scale(.95); background: #ffffff33; }
.pad .wide { grid-column: span 2; font-size: 22px; }
input.text { width: 100%; min-height: 68px; border-radius: 20px; border: 2px solid var(--line); background: #00000040; padding: 0 20px;
  font-size: 30px; font-weight: 800; outline: none; user-select: text; -webkit-user-select: text; }
input.text:focus { border-color: var(--accent); }

/* birthday picker */
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.days { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 10px; }
.months button, .days button { min-height: 56px; border-radius: 14px; background: #ffffff18; font-size: 19px; font-weight: 800; }
.months button[aria-pressed="true"], .days button[aria-pressed="true"] { background: var(--accent); color: #111; }

/* results */
.result { text-align: center; }
.big { font-size: clamp(28px, 5vw, 42px); font-weight: 900; line-height: 1.15; margin: 4px 0; }
.big em { font-style: normal; color: var(--accent); }
.sub { font-size: 19px; color: var(--dim); }
.strip { display: flex; justify-content: center; flex-wrap: nowrap; gap: 0; overflow: hidden; margin: 14px auto 6px; font-size: clamp(22px, 3.6vw, 34px); font-weight: 800; }
.strip span { padding: 4px 1px; }
.strip .hit { background: var(--hit); color: #111; border-radius: 8px; padding: 4px 3px; animation: pop .5s ease; }
.strip .dot { opacity: .4; }
.marks { display: flex; justify-content: space-between; font-size: 14px; color: var(--dim); max-width: 760px; margin: 0 auto; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: none; } }
.t9 { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.t9 span { display: grid; grid-template-rows: auto auto; text-align: center; background: #00000040; border-radius: 12px; padding: 6px 10px; font-weight: 900; font-size: 22px; }
.t9 span small { color: var(--accent); font-size: 17px; }
.compare { margin-top: 8px; font-size: 18px; color: var(--dim); }
.compare a { color: var(--accent); font-weight: 800; }

/* digit browser */
.dhead { position: sticky; top: -8px; z-index: 2; padding: 8px 0 10px; background: var(--bg2); box-shadow: 0 8px 12px -6px #0008; }
.dhead .row { gap: 8px; }
.dlist { position: relative; }
.drow { position: absolute; left: 0; right: 0; display: flex; align-items: center; height: 40px; }
.drow .at { width: 92px; flex: none; text-align: right; padding-right: 12px; font-size: 13px; color: var(--dim); }
.drow .g { margin-right: 14px; font-size: 24px; font-weight: 800; letter-spacing: .06em; white-space: nowrap; }
.drow .g i { font-style: normal; }
.drow .g i.h { background: var(--hit); color: #111 !important; border-radius: 5px; }
.drow .g i.f { text-decoration: underline 3px var(--accent2); text-underline-offset: 5px; }
.rainbow .c0 { color: var(--d0); } .rainbow .c1 { color: var(--d1); } .rainbow .c2 { color: var(--d2); } .rainbow .c3 { color: var(--d3); } .rainbow .c4 { color: var(--d4); }
.rainbow .c5 { color: var(--d5); } .rainbow .c6 { color: var(--d6); } .rainbow .c7 { color: var(--d7); } .rainbow .c8 { color: var(--d8); } .rainbow .c9 { color: var(--d9); }
.goto { display: flex; gap: 8px; align-items: center; }
.goto input { width: 210px; min-height: 56px; font-size: 22px; }

/* art */
.canvasbox { position: relative; width: 100%; height: max(300px, calc(100vh - 440px)); background: #00000055; border-radius: 24px; overflow: hidden; }
.canvasbox canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.legend span { min-width: 44px; padding: 6px 8px; border-radius: 10px; font-weight: 900; color: #111; text-align: center; font-size: 18px; }
.legend span b { font-weight: 600; font-size: 13px; display: block; }

/* counts */
.bars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; align-items: end; height: 300px; margin-top: 10px; }
.bars .b { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .fill { width: 100%; border-radius: 12px 12px 4px 4px; min-height: 4px; transition: height .12s linear; }
.bars .n { font-size: 15px; font-weight: 800; margin-bottom: 4px; white-space: nowrap; }
.bars .k { font-size: 26px; font-weight: 900; margin-top: 6px; }
.bars .crown { height: 30px; font-size: 26px; }

/* memorize */
.climb { font-size: clamp(28px, 4.6vw, 40px); font-weight: 900; text-align: center; min-height: 64px; letter-spacing: .05em; word-break: break-all; }
.climb .ok { color: #7dff9a; }
.climb .bad { color: #ff6b6b; text-decoration: line-through; }
.climb .next { color: var(--accent); animation: pop .4s; }
.score { display: flex; justify-content: center; gap: 24px; font-size: 20px; font-weight: 800; color: var(--dim); }
.score b { color: var(--ink); font-size: 28px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.study { font-size: 26px; font-weight: 800; letter-spacing: .06em; line-height: 1.6; word-break: break-all; }
.study span { margin-right: 14px; }

/* facts */
.facts { display: grid; gap: 10px; }
.fact { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; font-size: 20px; line-height: 1.35; animation: pop .35s ease both; }
.fact .em { font-size: 32px; line-height: 1; flex: none; width: 40px; text-align: center; }
.fact .no { flex: none; color: var(--dim); font-size: 14px; font-weight: 800; margin-top: 4px; }
.loading { text-align: center; color: var(--dim); font-size: 18px; padding: 20px; }

@media (max-width: 700px) {
  .bar { padding-left: 146px; }
  .bar h1 { font-size: 22px; }
  .tabs button { font-size: 12px; }
  .bar h1 span:last-child { display: none; }
  .tabs button b { font-size: 24px; }
  .pad { grid-template-columns: repeat(4, 1fr); }
  .months { grid-template-columns: repeat(4, 1fr); }
  .days { grid-template-columns: repeat(7, 1fr); }
  .drow .g { font-size: 19px; margin-right: 10px; }
  .drow .at { width: 70px; }
  .bars { height: 220px; gap: 4px; }
  .bars .n { font-size: 11px; }
}
@media (max-width: 480px) { .bar h1 { visibility: hidden; } .swap a { min-width: 52px; } }
