/* Kids Piano: its own look. The keyboard fills the screen under the top bar while playing. Calm by design: soft colors,
   a pressed key goes down and brightens over 0.4 s (ease in and out), nothing loops or moves by itself.
   The key colors live in one look class on <body> (look-rainbow, picked Oct 12); look-wood and look-classic are ready,
   so switching looks is one class in index.html. Nothing depends on color: every key has its name printed on it. */
:root {
  --bg: #f3eee4;
  --bg-2: #ebe2d1;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --radius: 20px;
  --top-h: 64px;
  color-scheme: light;
}

/* ---------- looks ---------- */
body.look-rainbow {
  --k-c: #e07a6a; --k-d: #e9a05a; --k-e: #e9c45a; --k-f: #8cbf6a; --k-g: #5fb3a6; --k-a: #6f8fd6; --k-b: #a77ccf;
  --white-ink: #2c2236; --sharp: #3b3550; --sharp-ink: #fff; --key-edge: #2c2236; --key-shine: #ffffff40;
}
body.look-wood {
  --k-c: #e8c79c; --k-d: #e3c093; --k-e: #e8c79c; --k-f: #e3c093; --k-g: #e8c79c; --k-a: #e3c093; --k-b: #e8c79c;
  --white-ink: #4a2f17; --sharp: #5a3a22; --sharp-ink: #fff4e2; --key-edge: #6b4526; --key-shine: #ffffff38;
}
body.look-classic {
  --k-c: #fffdf7; --k-d: #fffdf7; --k-e: #fffdf7; --k-f: #fffdf7; --k-g: #fffdf7; --k-a: #fffdf7; --k-b: #fffdf7;
  --white-ink: #2b2b33; --sharp: #2b2b33; --sharp-ink: #fff; --key-edge: #2b2b33; --key-shine: #ffffff00;
}

/* Evening: dimmer and warmer (rule 4). (No filter on main: the keyboard is fixed to the screen inside it.) */
body.evening { --bg: #e6dcc8; --bg-2: #dacdb4; --card: #f6eedc; }
body.evening #home, body.evening #finish, body.evening .top, body.evening #keys, body.evening .said { filter: brightness(.88) sepia(.08); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(circle at 10% 6%, #faf6ee 0 14%, transparent 15%), radial-gradient(circle at 92% 28%, var(--bg-2) 0 12%, transparent 13%), var(--bg);
  color: var(--ink);
  font: 500 18px/1.45 'Fredoka', system-ui, sans-serif;
  overscroll-behavior: none;
  overflow-x: hidden;
}
h1, h2 { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: #1f5fa8; }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 6px; min-height: 64px; }
.grow { flex: 1; }
.brand { display: block; width: 40px; height: 40px; }
.back, .round {
  min-height: 48px; min-width: 48px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card);
  box-shadow: 0 4px 0 var(--ink); font-weight: 700; padding: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.back:active, .round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#sound .mute, #sound .w2 { display: none; }
#sound[data-volume='loud'] .w2 { display: inline; }
#sound[data-volume='loud'] { background: var(--sun); }
#sound[data-volume='off'] .mute { display: inline; }
#sound[data-volume='off'] :is(.w1, .w2) { display: none; }

main { max-width: 1600px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: 18px; }

/* home */
.hero { text-align: center; display: grid; gap: 8px; padding-top: 4px; justify-items: center; }
.hero h1 { font-size: clamp(34px, 10vw, 54px); }
.lede { margin: 0; font-size: 20px; color: var(--soft); }
.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 76px;
  border: 3px solid var(--ink); border-radius: 24px; font-size: 30px; font-weight: 700; box-shadow: 0 7px 0 var(--ink); padding: 10px 20px;
}
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.big.go { background: var(--green); color: #fff; text-shadow: 0 2px 0 #0003; }
.big.plain { background: var(--card); font-size: 24px; min-height: 64px; }
.pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; min-width: 0; }
.pick legend { font-weight: 700; font-size: 18px; margin-bottom: 8px; padding: 0; }
.pick button {
  border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--ink); padding: 10px 4px;
  display: grid; justify-items: center; align-content: start; gap: 4px; font-weight: 700; font-size: 20px; line-height: 1.15; min-height: 96px;
}
.pick button small { font-size: 14px; font-weight: 500; color: var(--soft); }
.pick button[aria-pressed='true'] { background: #dff3e1; border-color: var(--green-d); box-shadow: 0 4px 0 var(--green-d); outline: 3px solid var(--green); outline-offset: 1px; }
.pick button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
/* Little key pictures on the two ways to play: three keys, or three keys with the middle one lit. */
.mini-keys { display: inline-flex; gap: 3px; height: 26px; }
.mini-keys i { width: 14px; border: 2px solid var(--ink); border-radius: 0 0 4px 4px; background: var(--k-c); }
.mini-keys i:nth-child(2) { background: var(--k-e); }
.mini-keys i:nth-child(3) { background: var(--k-g); }
.mini-keys.one i { opacity: .4; }
.mini-keys.one i:nth-child(2) { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips button { display: inline-flex; min-height: 48px; padding: 6px 14px; font-size: 18px; align-items: center; }
.grownups, .about { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 5px 0 #3b2a1a33; }
.grownups summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.grownups p, .about p { margin: 10px 0 0; }
.about h2 { font-size: 22px; margin-top: 14px; }
.about h2:first-child { margin-top: 0; }
.about h3 { font-size: 18px; margin: 12px 0 0; }
.about ul { padding-left: 22px; display: grid; gap: 6px; }
.small { font-size: 14px; color: var(--soft); }

/* ---------- the keyboard ---------- */
/* White keys sit side by side (--i is each one's place); a sharp sits on the line between two (--b). */
.keys { position: relative; --n: 10; --w: calc(100% / var(--n)); --gap: 3px; touch-action: none; user-select: none; -webkit-user-select: none; }
.key {
  position: absolute; margin: 0; padding: 0 0 12px; border: 3px solid var(--key-edge); border-top-width: 0; border-radius: 0 0 16px 16px;
  display: flex; align-items: flex-end; justify-content: center; font-weight: 700; line-height: 1;
  touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  transition: transform .4s ease-in-out, filter .4s ease-in-out;
}
.key.white {
  top: 0; bottom: 0; left: calc(var(--i) * var(--w) + var(--gap) / 2); width: calc(var(--w) - var(--gap)); z-index: 1;
  background: linear-gradient(var(--key-shine), #ffffff00 40%), var(--kc); color: var(--white-ink);
  box-shadow: inset 0 -10px 0 #00000014;
}
.key.sharp {
  top: 0; height: 60%; width: calc(var(--w) * .62); left: calc(var(--b) * var(--w) - var(--w) * .31); z-index: 2;
  background: linear-gradient(#ffffff1f, #ffffff00 50%), var(--sharp); color: var(--sharp-ink); border-color: #00000066;
  box-shadow: inset 0 -8px 0 #0000002e;
}
.key.white[data-l='C'] { --kc: var(--k-c); }
.key.white[data-l='D'] { --kc: var(--k-d); }
.key.white[data-l='E'] { --kc: var(--k-e); }
.key.white[data-l='F'] { --kc: var(--k-f); }
.key.white[data-l='G'] { --kc: var(--k-g); }
.key.white[data-l='A'] { --kc: var(--k-a); }
.key.white[data-l='B'] { --kc: var(--k-b); }
.nn { pointer-events: none; font-size: clamp(24px, min(5vw, 9vh), 52px); }
.sharp .nn { font-size: clamp(16px, min(2.8vw, 6vh), 32px); }
/* Pressed: the key goes down and brightens, then settles back (0.4 s each way). */
.key.white.down { transform: translateY(5px); filter: brightness(1.12) saturate(1.1); }
.key.sharp.down { transform: translateY(4px); filter: brightness(1.7); }
.key:focus-visible { outline: 4px solid var(--ink); outline-offset: -6px; }

/* The little keyboard on the home screen (always side by side). */
.demo.keys { width: min(92vw, 440px); height: 120px; touch-action: auto; }
.demo .nn { font-size: 18px; }
.demo .sharp .nn { font-size: 11px; }
.demo .key { padding-bottom: 6px; border-width: 2px; border-top-width: 0; border-radius: 0 0 8px 8px; }

/* ---------- playing: the keyboard fills the screen under the top bar ---------- */
body.playing { overflow: hidden; }
body.playing main { padding: 0; }
#play-screen {
  position: fixed; left: 0; right: 0; top: var(--top-h); bottom: 0; gap: 6px; grid-template-rows: auto auto 1fr;
  padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.said { margin: 0; min-height: 1.3em; text-align: center; font-size: clamp(22px, min(6vw, 7vh), 36px); font-weight: 700; color: var(--ink); line-height: 1.25; }
/* In a song: the word for the lit key, bold on a soft yellow, so it doesn't depend on color alone. */
.said .now { background: var(--sun); border-radius: 8px; padding: 0 4px; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.said .w { font-weight: 500; color: var(--soft); }
#play-screen #keys { min-height: 0; }

/* Phone held upright: the keys turn into long bars, C at the top to C at the bottom, names on the left; the sharps are
   shorter dark bars on the right, on the line between two. Keys above C5 wait for a phone held sideways. */
@media (orientation: portrait) {
  #keys { --n: 8; --h: calc(100% / var(--n)); --sh: max(56px, calc(var(--h) * .64)); }
  #keys .key.hi { display: none; }
  #keys .key { border-top-width: 3px; border-left-width: 0; padding: 0; align-items: center; border-radius: 0 16px 16px 0; }
  #keys .key.white { left: 0; right: 0; width: auto; top: calc(var(--i) * var(--h) + var(--gap) / 2); bottom: auto; height: calc(var(--h) - var(--gap)); justify-content: flex-start; padding-left: 22px; box-shadow: inset -10px 0 0 #00000014; }
  #keys .key.sharp { left: auto; right: 0; width: 42%; top: calc(var(--b) * var(--h) - var(--sh) / 2); height: var(--sh); justify-content: flex-end; padding-right: 18px; border-radius: 16px 0 0 16px; border-right-width: 0; border-left-width: 3px; }
  #keys .nn { font-size: clamp(26px, min(8vw, 6vh), 52px); }
  #keys .sharp .nn { font-size: clamp(18px, min(5vw, 3.6vh), 32px); }
  #keys .key.white.down { transform: translateX(5px); }
  #keys .key.sharp.down { transform: translateX(-4px); }
}

/* ---------- finish ---------- */
#finish { text-align: center; padding-top: 10px; max-width: 900px; margin: 0 auto; width: 100%; }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.talk { margin: 0; background: #f4fbf6; border: 2px dashed var(--green-d); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; }

/* Phones held sideways: a slimmer top bar, so the keys get the room. */
@media (orientation: landscape) and (max-height: 520px) {
  .top { min-height: 52px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .said { font-size: clamp(20px, 6vh, 28px); }
}

/* The full lock (kids.css): All done's own buttons hide while locked; the six play buttons show there instead. */
.locked-only { display: none; }
body.locked .locked-only { display: block; }
body.locked #done-modes { display: grid; }
body.locked #finish .big { display: none; }

/* The switch above the keys: Free play and the five songs, six equal buttons (one row wide, 3 + 3 on a narrow screen). */
.modes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding-top: 6px; }
.modes button {
  min-height: 48px; border: 3px solid var(--ink); border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 6px; font-weight: 700; font-size: 16px; line-height: 1.1;
}
.modes button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.modes button[aria-pressed='true'] { background: #dff3e1; border-color: var(--green-d); box-shadow: 0 3px 0 var(--green-d); }
.modes .mn { font-size: 20px; }
.modes .mk { display: inline-flex; gap: 2px; height: 18px; }
.modes .mk i { width: 8px; border: 2px solid var(--ink); border-radius: 0 0 3px 3px; background: var(--k-c); }
.modes .mk i:nth-child(2) { background: var(--k-e); }
.modes .mk i:nth-child(3) { background: var(--k-g); }
@media (max-width: 700px) { .modes { grid-template-columns: repeat(3, 1fr); } .modes button { font-size: 14px; min-height: 44px; padding: 4px 3px; text-align: center; } .modes .mn { display: none; } }
@media (orientation: landscape) and (max-height: 520px) { .modes button { min-height: 40px; font-size: 14px; } }
