/* Dinotchi — a soft plastic handheld around a living little screen.
   Shell colours come from [data-shell] on <html>. */

:root {
  --shell: #bfe8d2;
  --shell-hi: #e2f7ea;
  --shell-lo: #96d3b4;
  --shell-edge: #7cbf9d;
  --bg-a: #e9f6ee;
  --bg-b: #cfe6dc;
  --blob-1: rgba(255, 252, 238, 0.9);
  --blob-2: rgba(150, 220, 190, 0.55);
  --blob-3: rgba(255, 210, 160, 0.4);
  --ink: #1f3a2f;
  --ink-soft: #557265;
  --key: #fffdf6;
  --key-lo: #e9e3d3;
  --key-ink: #2d3b35;
  --accent: #ff8a3d;
  --accent-2: #2fae7a;
  --danger: #e2574c;
  --paper: #fbfaf5;
  --paper-2: #eef3ec;
  --line: rgba(31, 58, 47, 0.12);
  --bezel: #2c3140;
  --bezel-hi: #3b4153;
  --radius: 18px;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.3, 1.4, 0.5, 1);
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --controls-h: 152px;
  --key-h: 64px;
}

[data-shell="peach"] {
  --shell: #ffd3bd; --shell-hi: #ffeadf; --shell-lo: #f4b296; --shell-edge: #e39a7a;
  --bg-a: #fff1e8; --bg-b: #f6dccd;
  --blob-2: rgba(255, 180, 150, 0.5); --blob-3: rgba(255, 230, 150, 0.45);
  --ink: #4a2a1e; --ink-soft: #8a5e4c; --accent-2: #e46f48;
}
[data-shell="lilac"] {
  --shell: #d9d0fb; --shell-hi: #eeeaff; --shell-lo: #bcaef0; --shell-edge: #a596e2;
  --bg-a: #f3f0ff; --bg-b: #ddd6f6;
  --blob-2: rgba(190, 170, 255, 0.5); --blob-3: rgba(255, 190, 220, 0.4);
  --ink: #2f2652; --ink-soft: #6b6192; --accent-2: #7b62e0;
}
[data-shell="night"] {
  --shell: #2f3550; --shell-hi: #424a6a; --shell-lo: #232840; --shell-edge: #1a1e33;
  --bg-a: #161a2c; --bg-b: #0f1222;
  --blob-1: rgba(80, 90, 160, 0.35); --blob-2: rgba(60, 140, 130, 0.3); --blob-3: rgba(160, 90, 160, 0.25);
  --ink: #eef0ff; --ink-soft: #a6abcc;
  --key: #444b6b; --key-lo: #2f3550; --key-ink: #f1f2ff;
  --paper: #23283d; --paper-2: #2e3450; --line: rgba(255, 255, 255, 0.1);
  --bezel: #12141f; --bezel-hi: #20243a; --accent-2: #5fd3a3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-a), var(--bg-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  transition: background 0.6s;
}

/* ---------------------------------------------------------- background */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.6; will-change: transform; }
.bg .b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: var(--blob-1); animation: drift 48s ease-in-out infinite alternate; }
.bg .b2 { width: 50vmax; height: 50vmax; right: -20vmax; bottom: -20vmax; background: var(--blob-2); animation: drift 60s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 40vmax; height: 40vmax; left: 30vw; bottom: -25vmax; background: var(--blob-3); animation: drift 72s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.12); } }

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 2px 16px;
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2)); }
.brand span { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand b { font-family: var(--round); font-weight: 800; font-size: 23px; letter-spacing: 0.01em; }
.brand small { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; gap: 2px; flex: 0 0 auto; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  flex: 0 0 auto;
}
.icon-btn:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.icon-btn:active { transform: scale(0.9); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg { width: 22px; height: 22px; }

/* -------------------------------------------------------------- device */
.device {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: calc(100% - 20px);
  max-width: 460px;
  margin: 6px 10px 10px;
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 34px;
  background:
    radial-gradient(120% 60% at 20% 0%, var(--shell-hi), transparent 60%),
    linear-gradient(165deg, var(--shell-hi), var(--shell) 40%, var(--shell-lo));
  box-shadow:
    0 24px 50px -18px color-mix(in oklab, var(--shell-edge) 70%, #000 30%),
    0 3px 0 var(--shell-edge),
    inset 0 2px 1px rgba(255, 255, 255, 0.65),
    inset 0 -10px 22px rgba(0, 0, 0, 0.07);
}
[data-shell="night"] .device { box-shadow: 0 24px 50px -18px #000, 0 3px 0 var(--shell-edge), inset 0 2px 1px rgba(255, 255, 255, 0.12), inset 0 -10px 22px rgba(0, 0, 0, 0.25); }

/* needs */
.meters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  flex: 0 0 auto;
  min-height: 30px;
}
.meter {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 12px;
  background: color-mix(in oklab, var(--key) 70%, transparent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  min-width: 0;
}
.meter svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--c); stroke-width: 2.1; }
.meter .bar { flex: 1 1 auto; height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.1); overflow: hidden; min-width: 0; }
.meter .bar i { display: block; height: 100%; width: 50%; border-radius: inherit; background: var(--c); transition: width 0.6s var(--ease), background 0.4s; }
.meter.low { animation: low 1.1s ease-in-out infinite; }
.meter.low .bar i { background: var(--danger); }
@keyframes low { 50% { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 2px color-mix(in oklab, var(--danger) 55%, transparent); } }
.meters.egg { grid-template-columns: 1fr; }
.meter.wide { gap: 8px; padding: 6px 10px; }
.meter.wide span { font-size: 12px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }

/* the screen */
.bezel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 10px 10px;
  border-radius: 24px 24px 30px 24px;
  background: linear-gradient(180deg, var(--bezel-hi), var(--bezel));
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.5);
}
.bezel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 16px;
  padding: 0 4px 4px;
  font: 700 8.5px/1 var(--sans);
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.38);
  flex: 0 0 auto;
}
.bezel-label span { white-space: nowrap; overflow: hidden; }
.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5b4f;
  box-shadow: 0 0 6px #ff5b4f;
  flex: 0 0 auto;
}
.led.on { animation: led 1.1s ease-in-out infinite; }
.led.idle { background: #5ee08f; box-shadow: 0 0 6px #5ee08f; }
@keyframes led { 50% { opacity: 0.35; } }
.screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  overflow: hidden;
  background: #0d1117;
}
.screen canvas { display: block; border-radius: 12px; touch-action: none; cursor: pointer; }
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 32%), radial-gradient(130% 100% at 50% 50%, transparent 70%, rgba(0, 0, 0, 0.28));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.toast {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 2;
  max-width: calc(100% - 24px);
  transform: translate(-50%, -12px);
  opacity: 0;
  padding: 7px 14px;
  border-radius: 14px;
  background: rgba(24, 26, 40, 0.82);
  color: #fff;
  font: 600 13.5px/1.3 var(--sans);
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s, transform 0.3s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* name, stage, mood */
.caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  padding: 0 4px;
  flex: 0 0 auto;
}
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who b { font: 800 17px/1.1 var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  font: 700 11px/1 var(--sans);
  font-style: normal;
  letter-spacing: 0.04em;
  padding: 5px 8px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--key) 75%, transparent);
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip:empty { display: none; }
.mood {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 13px/1 var(--sans);
  color: var(--ink-soft);
  white-space: nowrap;
}
.mood::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--mood, #5ee08f); box-shadow: 0 0 0 3px color-mix(in oklab, var(--mood, #5ee08f) 25%, transparent); }
.mood:empty::before { display: none; }

/* -------------------------------------------------------------- controls */
.controls {
  position: relative;
  flex: 0 0 var(--controls-h);
  height: var(--controls-h);
  display: flex;
  flex-direction: column;
}
.panel { display: flex; flex-direction: column; height: 100%; gap: 8px; animation: panel 0.25s var(--ease); }
@keyframes panel { from { opacity: 0; transform: translateY(6px); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 28px; flex: 0 0 auto; }
.panel-head h3 { margin: 0; font: 800 14.5px/1.2 var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .icon-btn { width: 34px; height: 34px; background: color-mix(in oklab, var(--key) 70%, transparent); }
.panel-body { flex: 1 1 auto; min-height: 0; }

.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; height: 100%; align-content: center; }

.key {
  appearance: none;
  position: relative;
  border: 0;
  height: var(--key-h);
  min-width: 0;
  padding: 6px 4px 5px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--key-ink);
  background: linear-gradient(180deg, var(--key), color-mix(in oklab, var(--key) 88%, var(--key-lo)));
  box-shadow: 0 4px 0 var(--key-lo), 0 6px 12px -6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font: 700 11.5px/1.1 var(--sans);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}
[data-shell="night"] .key { box-shadow: 0 4px 0 #1d2136, 0 6px 12px -6px #000, inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--key-lo), 0 2px 6px -4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
.key svg { width: 25px; height: 25px; color: var(--c, var(--accent-2)); stroke-width: 2; }
.key span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key.dim { opacity: 0.5; }
.key.alert::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--key);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.35); } }
.key.big { flex-direction: row; gap: 8px; font-size: 14px; }
.key.big svg { width: 24px; height: 24px; }
.key.good { --c: #2fae7a; }
.key.bad { --c: #e2574c; }
.key.hot { background: linear-gradient(180deg, #ffb070, #ff8a3d); color: #fff; --c: #fff; box-shadow: 0 4px 0 #d8682a, 0 6px 12px -6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.key:disabled { opacity: 0.42; cursor: default; transform: none; }

.k-feed { --c: #e9813f; }
.k-play { --c: #3f9ae9; }
.k-train { --c: #7b62e0; }
.k-tricks { --c: #e6a91a; }
.k-bath { --c: #34b3d9; }
.k-sleep { --c: #5b5ad6; }
.k-medicine { --c: #e2574c; }
.k-pet { --c: #ec5f97; }

/* food, games, eggs */
.cards { display: grid; gap: 8px; height: 100%; }
.cards.c4 { grid-template-columns: repeat(4, 1fr); }
.cards.c3 { grid-template-columns: repeat(3, 1fr); }
.cards.c2 { grid-template-columns: repeat(2, 1fr); }
.card {
  appearance: none;
  border: 0;
  position: relative;
  min-width: 0;
  border-radius: 18px;
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--key-ink);
  background: linear-gradient(180deg, var(--key), color-mix(in oklab, var(--key) 88%, var(--key-lo)));
  box-shadow: 0 4px 0 var(--key-lo), 0 6px 12px -6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font: 700 12.5px/1.15 var(--sans);
  transition: transform 0.12s, box-shadow 0.12s, outline-color 0.2s;
  outline: 3px solid transparent;
  outline-offset: 2px;
}
.card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--key-lo); }
.card canvas { width: 46px; height: 46px; }
.card small { font-weight: 600; font-size: 10.5px; color: color-mix(in oklab, var(--key-ink) 60%, transparent); }
.card .tag {
  position: absolute;
  top: 5px;
  right: 5px;
  font: 800 9px/1 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 5px;
  border-radius: 6px;
  background: #ffe1ec;
  color: #c2185b;
}
.card .tag.no { background: #eceff3; color: #6b7280; }
.card.selected { outline-color: var(--accent); }
.card.game { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 12px; text-align: left; }
.card.game svg { width: 34px; height: 34px; flex: 0 0 auto; color: var(--c); stroke-width: 2; }
.card.game span { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 14px; }

.select { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.select .cards { height: auto; flex: 1 1 auto; min-height: 0; }
.select .card { padding: 4px; }
.select .card canvas { width: 40px; height: 48px; }
.select-row { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.select-row p { flex: 1 1 auto; margin: 0; font-size: 12px; line-height: 1.3; color: var(--ink-soft); min-width: 0; }
.select-row .btn { flex: 0 0 auto; }

/* trick chips */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; height: 100%; overflow: auto; overscroll-behavior: contain; padding: 2px 2px 6px; align-content: start; }
.chip-btn {
  appearance: none;
  border: 0;
  position: relative;
  min-width: 0;
  min-height: 46px;
  border-radius: 14px;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  color: var(--key-ink);
  background: linear-gradient(180deg, var(--key), color-mix(in oklab, var(--key) 90%, var(--key-lo)));
  box-shadow: 0 3px 0 var(--key-lo), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font: 700 12.5px/1.1 var(--sans);
  text-align: left;
  transition: transform 0.12s;
}
.chip-btn:active { transform: translateY(2px); }
.chip-btn span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-btn .prog { width: 100%; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.1); overflow: hidden; }
.chip-btn .prog i { display: block; height: 100%; background: linear-gradient(90deg, #7b62e0, #b18cff); border-radius: inherit; }
.chip-btn.learned .prog i { background: linear-gradient(90deg, #e6a91a, #ffd34d); }
.chip-btn.learned::after {
  content: "★";
  position: absolute;
  top: 4px;
  right: 7px;
  font-size: 12px;
  color: #e6a91a;
}
.chip-btn.locked { opacity: 0.55; cursor: default; }
.chip-btn.locked small { font: 600 10px/1 var(--sans); color: var(--ink-soft); display: flex; align-items: center; gap: 3px; }
.chip-btn.locked small svg { width: 11px; height: 11px; }
.chip-btn.special { background: linear-gradient(180deg, #fff6d8, #ffe9a8); color: #5a3f00; }
[data-shell="night"] .chip-btn.special { background: linear-gradient(180deg, #5d5432, #463e22); color: #ffefb8; }

/* training */
.train { display: grid; grid-template-columns: 1.25fr 1fr 1fr; grid-template-rows: auto 1fr; gap: 8px; height: 100%; }
.train .skill { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font: 700 12px/1 var(--sans); color: var(--ink-soft); }
.train .skill .prog { flex: 1 1 auto; height: 9px; border-radius: 5px; background: rgba(0, 0, 0, 0.1); overflow: hidden; }
.train .skill .prog i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7b62e0, #b18cff); transition: width 0.6s var(--spring); }
.train .skill.learned .prog i { background: linear-gradient(90deg, #e6a91a, #ffd34d); }
.train .skill b { min-width: 38px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.train .key { height: 100%; font-size: 13px; }
.train .key svg { width: 28px; height: 28px; }

.gamepad { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; height: 100%; }
.gamepad .key { height: 100%; font-size: 14px; }
.gamepad .key svg { width: 30px; height: 30px; }
.gamepad.solo { grid-template-columns: 1fr; }

.egg-panel { display: flex; flex-direction: column; gap: 10px; height: 100%; justify-content: center; }
.egg-panel p { margin: 0; text-align: center; font-size: 13px; color: var(--ink-soft); }
.egg-panel .key { height: 64px; flex-direction: row; gap: 10px; font-size: 15px; }

/* -------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 0;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font: 700 14.5px/1 var(--sans);
  color: var(--key-ink);
  background: var(--key);
  box-shadow: 0 3px 0 var(--key-lo), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: transform 0.12s, filter 0.2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-lo); }
.btn.primary { background: linear-gradient(180deg, #ffa060, #ff7a2f); color: #fff; box-shadow: 0 3px 0 #cf5d1c, inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.btn.danger { background: linear-gradient(180deg, #f07167, #dc4a40); color: #fff; box-shadow: 0 3px 0 #a8342c, inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn.wide { width: 100%; }
.btn svg { width: 19px; height: 19px; }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(20, 30, 28, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 520px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(20, 30, 28, 0.25);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
  -webkit-user-select: text;
  user-select: text;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; flex: 0 0 auto; }
.sheet h2 { font: 800 23px/1.2 var(--round); margin: 0; }
.sheet-body { overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 22px 26px; font-size: 15px; line-height: 1.55; }
.sheet-body h3 { font: 800 15px/1.2 var(--round); margin: 22px 0 10px; letter-spacing: 0.01em; }
.rules p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 26px; max-height: 82dvh; animation: pop 0.28s var(--ease); }
  @keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }
}
.sheet-small { max-width: 400px; }

/* profile */
.profile-card { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 20px; background: var(--paper-2); }
.profile-card canvas { width: 104px; height: 104px; flex: 0 0 auto; border-radius: 16px; background: linear-gradient(180deg, #bfe7ff, #e9f7ff 70%, #a6d97f 70%); }
.profile-card h4 { margin: 0 0 6px; font: 800 21px/1.1 var(--round); overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 700; }
.stars { color: #e6a91a; letter-spacing: 1px; }
.growth { margin-top: 12px; }
.growth .bar, .trick-row .bar { height: 9px; border-radius: 5px; background: color-mix(in oklab, var(--ink) 10%, transparent); overflow: hidden; }
.growth .bar i, .trick-row .bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2fae7a, #8fe3b0); }
.growth small { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 12.5px; }
.trick-list { display: grid; gap: 8px; }
.trick-row { display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: center; gap: 10px; font-size: 14px; }
.trick-row b { font-weight: 700; }
.trick-row em { font-style: normal; font-size: 12px; color: var(--ink-soft); min-width: 44px; text-align: right; }
.trick-row.learned .bar i { background: linear-gradient(90deg, #e6a91a, #ffd34d); }
.trick-row.locked { opacity: 0.5; }
.acc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.acc {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 8px 4px;
  background: var(--paper-2);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font: 700 12px/1.2 var(--sans);
  cursor: pointer;
}
.acc canvas { width: 44px; height: 44px; }
.acc small { font-weight: 600; font-size: 10.5px; color: var(--ink-soft); text-align: center; }
.acc.on { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, var(--paper-2)); }
.acc:disabled { opacity: 0.5; cursor: default; }
.journal { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.journal li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; font-size: 14px; }
.journal time { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }

/* settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting > span { font-weight: 600; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--paper-2); gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--ink); padding: 7px 11px; border-radius: 9px; font: 600 13px/1 var(--sans); cursor: pointer; }
.seg button.on { background: var(--paper); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
[data-shell="night"] .seg button.on { background: #4a5276; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.swatch { appearance: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--paper); box-shadow: 0 0 0 2px transparent; cursor: pointer; background: var(--sw); }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.swatch.auto { background: conic-gradient(#bfe8d2 0 50%, #2f3550 0); }
.setting.col { flex-direction: column; align-items: stretch; }
.setting.col p { margin: 0; font-size: 13px; color: var(--ink-soft); }

.name-form { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.name-egg { width: 96px; height: 96px; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  padding: 0 14px;
  font: 800 19px/1 var(--round);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.field input:focus { border-color: var(--accent); }
.field .icon-btn { background: var(--paper-2); width: 48px; height: 48px; border-radius: 14px; }

.confirm { text-align: center; padding-top: 24px; }
.confirm p { font-size: 16px; margin: 0 0 18px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* -------------------------------------------------------------- screen sizes */
@media (min-height: 760px) {
  :root { --controls-h: 166px; --key-h: 72px; }
}
/* -------------------------------------------------------------- small screens */
@media (max-height: 700px) {
  :root { --controls-h: 140px; --key-h: 58px; }
  .device { gap: 8px; padding: 10px 10px 12px; }
  .bezel-label { display: none; }
  .bezel { padding-top: 8px; }
}
@media (max-height: 600px) {
  :root { --controls-h: 128px; --key-h: 54px; }
  .key { font-size: 10.5px; }
  .key svg { width: 22px; height: 22px; }
}
@media (max-width: 380px) {
  .brand small { display: none; }
  .brand b { font-size: 21px; }
  .meter { padding: 5px 5px; gap: 3px; }
  .meter svg { width: 14px; height: 14px; }
  .key { font-size: 10.5px; border-radius: 16px; }
  .device { width: calc(100% - 12px); margin: 4px 6px 8px; border-radius: 28px; }
  .chips { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob, .meter.low, .key.alert::after, .led.on { animation: none; }
}
