/* ブラウザピアノ（全画面の楽器。色は端末のライト／ダークに合わせる） */
:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --text: #2b2620;
  --muted: #6b6259;
  --accent: #8b4513;
  --border: #d8cfc2;
  --down: #f2c38a;
  --down-black: #b3702f;
  font-family: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1d1a;
    --card: #2a2724;
    --text: #efe9e1;
    --muted: #b3a99c;
    --accent: #e0a060;
    --border: #4a443d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body.piano-page { overflow: hidden; overscroll-behavior: none; }

.piano-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 上の操作バー（1 行。狭いときは折り返す） */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.bar-title { font-size: 15px; margin: 0 4px 0 0; white-space: nowrap; }
.group { display: flex; align-items: center; gap: 4px; }
.ctl {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ctl:disabled { opacity: 0.4; cursor: default; }
.ctl.toggle[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.range { min-width: 5.5em; text-align: center; font-variant-numeric: tabular-nums; }
.seg { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; gap: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 9px; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.vol input { width: 90px; }
.vol-label { color: var(--muted); }
.click input { width: 4.2em; min-height: 44px; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); padding: 0 6px; }
.help { margin-left: auto; }

/* 鍵盤 */
.stage {
  flex: 1 1 auto;
  min-height: 120px;
  position: relative;
  display: flex;
  align-items: center;
  padding: 6px 6px 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.keys { position: relative; width: 100%; height: 100%; max-height: 100%; }
.key {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding-bottom: 8px;
  font-size: 14px;
  line-height: 1.1;
}
.key.white {
  height: 100%;
  background: linear-gradient(#fff 0%, #fff 88%, #eeeae4 100%);
  color: #3a332c;
  border: 1px solid #9c9489;
  border-radius: 0 0 7px 7px;
  z-index: 1;
}
.key.black {
  height: 62%;
  background: linear-gradient(#3a3632, #141210);
  color: #e8e2da;
  border-radius: 0 0 5px 5px;
  z-index: 2;
  font-size: 12px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}
.key.white.down { background: var(--down); }
.key.black.down { background: var(--down-black); }
.key .name { font-weight: 600; }
.key .kbd {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  opacity: 0.75;
  min-height: 1em;
}
.key.middle-c .name { border-bottom: 3px solid var(--accent); }

.rotate-hint { display: none; margin: 4px 10px; font-size: 13px; color: var(--muted); text-align: center; }
html.narrow .rotate-hint { display: block; }
@media (orientation: landscape) { html.narrow .rotate-hint { display: none; } }

.mini-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  justify-content: center;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}
.mini-foot a { color: var(--muted); }

/* 横向きのスマホ（高さが低い）: バーを 1 行に詰め、タイトルを隠す */
@media (max-height: 480px) {
  .bar { flex-wrap: nowrap; padding: 4px 8px; gap: 6px; overflow-x: auto; }
  .bar-title, .vol-label { display: none; }
  .ctl { padding: 0 8px; }
  .seg span { padding: 0 8px; }
  .vol input { width: 70px; }
  .mini-foot { padding: 2px 8px; }
}
