:root {
  color-scheme: light;
  --ink: #3b3278;
  --ink-soft: #7269a1;
  --mint: #70e3ce;
  --pink: #ff93cd;
  --cloud: rgba(255, 255, 255, .84);
  --line: rgba(255, 255, 255, .96);
  --shadow: 0 5px 0 rgba(82, 67, 133, .18), 0 12px 30px rgba(77, 66, 135, .13);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: linear-gradient(155deg, #b7c9ff 0%, #e4caf8 58%, #ffddce 100%);
  color: var(--ink);
}

button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #f086c1; outline-offset: 4px; }
[hidden] { display: none !important; }

.game { position: relative; isolation: isolate; width: 100%; height: 100svh; min-height: 600px; overflow: hidden; }
.playfield { position: absolute; z-index: 0; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }

.toolbar {
  position: absolute;
  z-index: 5;
  top: clamp(12px, 2.5vh, 26px);
  left: clamp(14px, 3.2vw, 48px);
  right: clamp(14px, 3.2vw, 48px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.brand {
  justify-self: start;
  color: #493585;
  font-size: clamp(23px, 2.1vw, 35px);
  font-weight: 900;
  letter-spacing: -.055em;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .85);
}
.brand span { color: #564b8b; }
.stage-badge {
  max-width: min(420px, 38vw);
  overflow: hidden;
  padding: 11px 30px;
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 100px;
  background: rgba(255, 255, 255, .47);
  box-shadow: 0 3px 10px rgba(94, 81, 149, .06);
  color: #382f71;
  font-size: clamp(16px, 1.4vw, 22px);
  font-weight: 850;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(14px);
}

.sound-controls { justify-self: end; display: flex; align-items: center; gap: clamp(8px, 1vw, 16px); }
.round-button, .picker-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: clamp(44px, 4.4vw, 66px);
  height: clamp(44px, 4.4vw, 66px);
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  box-shadow: 0 4px 12px rgba(82, 67, 133, .1);
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease, opacity .18s ease;
  backdrop-filter: blur(10px);
}
.round-button:hover, .picker-button:hover { transform: translateY(-2px); background-color: #fff; }
.round-button[aria-pressed="false"] { opacity: .58; }
.round-button svg, .picker-button svg { width: 25px; height: 25px; fill: none; stroke: #4b3d85; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.screen {
  position: absolute;
  z-index: 4;
  left: 50%;
  width: min(92vw, 790px);
  transform: translateX(-50%);
  text-align: center;
}
.welcome { top: clamp(94px, 13vh, 146px); }
.welcome h1, .result-screen h1, .pause-screen h1, .computer-message h1 {
  margin: 0 0 13px;
  color: #352b75;
  font-size: clamp(34px, 4vw, 62px);
  font-weight: 900;
  letter-spacing: -.045em;
  line-height: 1.13;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .78), 0 5px 16px rgba(91, 72, 153, .13);
}
.instruction { margin: 3px 0; font-size: clamp(18px, 1.8vw, 25px); font-weight: 800; line-height: 1.37; }
.instruction strong { font-size: 1.16em; }
.letter-f { color: #11a78e; }
.letter-j { color: #d94b9e; }
.finger-hint { margin: 7px 0 13px; color: #70689c; font-size: clamp(15px, 1.35vw, 20px); font-weight: 700; }
.welcome-reminder { display: grid; justify-items: center; gap: 6px; }
.action-hint { font-size: clamp(16px, 1.55vw, 22px); font-weight: 800; line-height: 1.65; }
.release-hint { color: var(--ink-soft); font-size: clamp(14px, 1.22vw, 17px); font-weight: 700; }
kbd.mini-key {
  display: inline-grid;
  place-items: center;
  position: relative;
  min-width: 38px;
  height: 38px;
  margin: 0 3px;
  border-radius: 11px;
  font-size: .95em;
  font-weight: 900;
  vertical-align: middle;
  box-shadow: 0 3px 0 rgba(73, 67, 119, .19);
}
.mini-key-f { border: 1px solid #78e8d6; background: rgba(143, 247, 222, .78); color: #126d62; }
.mini-key-j { border: 1px solid #ffa8d8; background: rgba(255, 213, 234, .88); color: #b23480; }
.mini-key-f::after, .mini-key-j::after { position: absolute; right: 12px; bottom: 5px; left: 12px; height: 2px; border-radius: 2px; background: currentColor; content: ""; }

.stage-picker { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }
.stage-picker > span { min-width: 175px; font-size: clamp(14px, 1.16vw, 17px); font-weight: 800; }
.picker-button { width: 37px; height: 37px; background: rgba(255, 255, 255, .7); }
.picker-button svg { width: 21px; height: 21px; }
.picker-button:disabled { cursor: default; opacity: .36; transform: none; }

.live-status {
  position: absolute;
  z-index: 4;
  top: clamp(82px, 11vh, 113px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 15px;
  border-radius: 100px;
  background: rgba(255, 255, 255, .28);
  color: #655a98;
  font-size: clamp(14px, 1.2vw, 17px);
  font-weight: 760;
  transform: translateX(-50%);
}
.status-separator { color: rgba(89, 78, 143, .55); }

.keyboard-island {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(5px, .85vh, 9px);
  min-height: clamp(280px, 37vh, 460px);
  padding: 12px 20px max(17px, env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, .85);
  border-bottom: 0;
  border-radius: 45% 45% 0 0 / 24px 24px 0 0;
  background: rgba(244, 243, 255, .75);
  box-shadow: 0 -8px 35px rgba(255, 255, 255, .4), inset 0 2px 8px rgba(255, 255, 255, .75);
  backdrop-filter: blur(13px);
}
.key-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: clamp(4px, .55vw, 9px); width: min(950px, calc(100vw - 44px)); }
.key-row-bottom { grid-template-columns: repeat(6, minmax(0, 1fr)); width: min(570px, calc(65vw - 26px)); }
.letter-key {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(39px, 5vh, 56px);
  border: 1px solid rgba(255, 255, 255, .98);
  border-radius: clamp(9px, 1vw, 16px);
  background: linear-gradient(155deg, #fff 0%, rgba(247, 246, 255, .98) 100%);
  box-shadow: 0 4px 0 rgba(107, 94, 150, .24), 0 8px 12px rgba(82, 67, 133, .08), inset 0 1px 0 rgba(255, 255, 255, 1);
  color: #4c437f;
  font-size: clamp(19px, 2.1vw, 29px);
  font-weight: 900;
  line-height: 1;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.letter-key::after { position: absolute; right: 37%; bottom: 6px; left: 37%; height: 0; border-radius: 5px; background: transparent; content: ""; }
.letter-key[data-key="f"] { border: 2px solid rgba(101, 230, 209, .88); background: linear-gradient(150deg, #b9fff0, #83f0db); color: #197d71; box-shadow: 0 3px 0 #56c9b7, 0 6px 13px rgba(74, 205, 184, .29), inset 0 1px 0 white; }
.letter-key[data-key="j"] { border: 2px solid rgba(255, 146, 203, .85); background: linear-gradient(150deg, #ffe2f2, #ffb7dc); color: #bd477e; box-shadow: 0 3px 0 #e98bbb, 0 6px 13px rgba(225, 113, 173, .22), inset 0 1px 0 white; }
.letter-key[data-key="f"]::after, .letter-key[data-key="j"]::after { right: 41%; bottom: 4px; left: 41%; height: 3px; background: currentColor; }
.letter-key.is-target { transform: translateY(-3px) scale(1.05); background: #fff9ce; color: #745593; box-shadow: 0 0 0 4px rgba(255, 240, 169, .72), 0 6px 14px rgba(81, 64, 133, .16); }
.letter-key.is-wrong { animation: gentle-wiggle .24s ease-in-out 2; }
.keyboard-caption { min-height: 18px; margin: 2px 0 0; color: #675e95; font-size: clamp(12px, 1.1vw, 16px); font-weight: 750; text-align: center; }
.mode-picker { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 9px; }
.mode-choice { display: grid; justify-items: center; gap: 2px; min-width: 176px; min-height: 43px; padding: 6px 14px; border: 1px solid rgba(255,255,255,.92); border-radius: 14px; background: rgba(255,255,255,.45); color: #5e548d; font-size: 14px; font-weight: 850; line-height: 1.15; cursor: pointer; transition: background-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.mode-choice[aria-pressed="true"] { border-color: rgba(133,112,214,.62); background: rgba(250,248,255,.93); box-shadow: 0 3px 9px rgba(83,66,142,.1); color: #403579; }
.mode-choice small { color: #766c9f; font-size: 11px; font-weight: 700; }
.mode-choice:hover { transform: translateY(-1px); background: rgba(255,255,255,.88); }
@keyframes gentle-wiggle { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }

.footer {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: max(3px, env(safe-area-inset-bottom));
  left: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 clamp(16px, 3.4vw, 50px);
  color: rgba(67, 58, 125, .74);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; pointer-events: auto; }

.result-screen { top: 27%; display: grid; justify-items: center; gap: 10px; }
.result-screen h1 { margin-bottom: 2px; font-size: clamp(39px, 5vw, 70px); }
.result-message { max-width: 630px; margin: 0 0 6px; color: #594f8d; font-size: clamp(19px, 2vw, 26px); font-weight: 750; line-height: 1.5; }
.result-actions { display: flex; justify-content: center; gap: 12px; margin-top: 5px; }
.secondary-button { min-height: 44px; padding: 10px 19px; border: 1px solid rgba(255,255,255,.93); border-radius: 100px; background: rgba(255,255,255,.75); box-shadow: 0 3px 10px rgba(73,58,127,.08); color: #4c417e; font-size: 15px; font-weight: 800; cursor: pointer; }
.secondary-button:hover { background: #fff; }
.pause-screen { top: 32%; width: min(92vw, 730px); padding: 24px; border: 1px solid rgba(255,255,255,.74); border-radius: 30px; background: rgba(252,251,255,.7); box-shadow: 0 18px 45px rgba(78, 63, 128, .14); backdrop-filter: blur(18px); }
.pause-screen h1 { font-size: clamp(32px, 4vw, 52px); }
.computer-message { display: grid; position: absolute; z-index: 9; inset: 0; align-content: center; justify-items: center; gap: 12px; padding: 32px; background: linear-gradient(152deg, #bbc9fa, #ead1f4 62%, #ffddd2); text-align: center; }
.computer-message h1 { max-width: 680px; font-size: clamp(35px, 7vw, 58px); }
.computer-message p { max-width: 580px; margin: 0; color: #60568e; font-size: clamp(18px, 2.2vw, 25px); font-weight: 740; line-height: 1.55; }
.computer-message a { margin-top: 12px; color: #44397e; font-weight: 800; text-underline-offset: 4px; }

@media (max-height: 820px) and (min-width: 901px) {
  .welcome { top: clamp(82px, 10vh, 92px); }
  .welcome h1 { margin-bottom: 7px; font-size: clamp(31px, 3vw, 40px); }
  .instruction { font-size: clamp(15px, 1.25vw, 17px); }
  .finger-hint { margin: 5px 0 7px; font-size: 15px; }
  .welcome-reminder { gap: 1px; }
  .welcome-reminder .action-hint { font-size: 16px; }
  .release-hint { font-size: 14px; }
  .mini-key { width: 31px; min-width: 31px !important; height: 31px !important; }
  .stage-picker { margin-top: 7px; }
  .keyboard-island { gap: 5px; padding-block: 8px; }
  .letter-key { height: clamp(37px, 5vh, 42px); }
  .keyboard-caption { min-height: 15px; margin-top: 0; }
  .mode-picker { gap: 6px; margin-top: 4px; }
  .mode-choice { min-width: 0; min-height: 37px; padding: 4px 12px; font-size: 13px; }
  .mode-choice small { font-size: 10px; }
  .footer { font-size: 10px; }
  .result-screen { top: 22%; }
}

@media (max-width: 900px), (max-height: 580px), (any-pointer: coarse) and (hover: none) {
  .welcome, .live-status, .result-screen, .pause-screen, .keyboard-island, .toolbar .stage-badge { visibility: hidden; }
  .computer-message[hidden] { display: none !important; }
  .computer-message:not([hidden]) { display: grid !important; }
  .toolbar .sound-controls { display: none; }
  .toolbar .stage-badge { max-width: 20px; padding: 0; border: 0; }
  .footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
