/*
  ドレミの けんばん だけの みため
  （いろなどの きほんは ../common/common.css に ある）
*/

:root {
  --color-good: #e0533b;      /* 「せいかい！」の もじ */
  --color-keyboard: #0d0e33;  /* けんばんの まわりの いろ */
  --color-black-key: #2a2856; /* くろい けんばん */
}

/* ===== がめん1: せってい ===== */
.setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 20px 28px;
}

.setting {
  width: 100%;
}

.setting-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  text-align: center;
}

/* モード（じゆうに ひこう・ひいてみよう・きいてあてよう） */
.mode-list {
  display: grid;
  gap: 8px;
}

.mode-choice,
.level-choice {
  border: 3px solid var(--color-line);
  border-radius: var(--radius-medium);
  background: #faf9ff;
  font-family: inherit;
  font-weight: 800;
  color: var(--color-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s;
}

.mode-choice:hover,
.level-choice:hover {
  border-color: #c9c5ee;
}

.mode-choice.is-on,
.level-choice.is-on {
  border-color: var(--color-main);
  background: #fff3ec;
}

.mode-choice:focus-visible,
.level-choice:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.mode-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-size: 1.05rem;
  text-align: left;
}

.mode-icon {
  flex: none;
  width: 36px;
  font-size: 1.5rem;
  text-align: center;
}

.mode-text small {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-sub);
}

/* むずかしさ（かずは main.js が --count に いれる） */
.level-list {
  display: grid;
  grid-template-columns: repeat(var(--count, 3), 1fr);
  gap: 6px;
}

.level-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 6px 4px;
  font-size: 0.9rem;
  line-height: 1.3;
  text-align: center;
  word-break: keep-all;
}

.level-choice small {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-sub);
}

.stars {
  font-size: 0.9rem;
  letter-spacing: 1px;
  color: #f5b800;
}

.stars-off {
  color: #dcdaf0;
}

.sound-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-sub);
  text-align: center;
  word-break: keep-all;
}

/* ===== がめん2: あそぶ ===== */
.play {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}

/* もんだい・せいかい */
.hud {
  display: flex;
  gap: 8px;
}

.hud-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 4px 4px 6px;
  border-radius: var(--radius-medium);
  background: rgba(255, 255, 255, 0.1);
}

.hud-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 1もんずつの けっか */
.dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.dots i.is-ok {
  background: var(--color-yellow);
}

.dots i.is-miss {
  background: rgba(255, 255, 255, 0.55);
}

/* もんだい */
.ask {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  padding: 12px 14px;
  border-radius: var(--radius-medium);
  text-align: center;
}

.ask p {
  margin: 0;
}

.ask-mode {
  font-size: 0.8rem;
  color: var(--color-text-sub);
}

.ask-main {
  font-size: 1.5rem;
  line-height: 1.4;
  word-break: keep-all;
}

/* 「ど」などの なまえを いろの ついた ふだに する */
.ask-name {
  display: inline-block;
  margin: 0 2px;
  padding: 0 14px;
  border-radius: 12px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.ask-sub {
  min-height: 1.5em;
  font-size: 0.95rem;
  color: var(--color-text-sub);
}

.ask-sub.is-good {
  color: var(--color-good);
}

.ask-sub.is-miss {
  color: var(--color-accent-dark);
}

.replay-button {
  min-height: 44px;
  padding: 6px 18px;
  font-size: 1rem;
}

/* けんばん */
.keyboard-wrap {
  display: flex;
  flex: 3 1 0; /* もんだいの わくより けんばんを ひろく とる */
  min-height: 150px;
  max-height: 340px;
}

.keyboard {
  position: relative;
  display: flex;
  flex: 1;
  gap: 4px;
  padding: 8px;
  border-radius: 18px;
  background: var(--color-keyboard);
  box-shadow: 0 12px 32px rgba(5, 6, 30, 0.45);
  touch-action: none; /* けんばんを おしても がめんが うごかない ように する */
  user-select: none;
  -webkit-user-select: none;
}

.key-white,
.key-black {
  border: none;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.key-white {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
  padding: 0 0 10px;
  border-radius: 0 0 12px 12px;
  background: #fff;
  color: var(--color-text);
  font-size: 1rem;
  box-shadow: inset 0 -6px 0 #dcdaf0;
  transition: transform 0.05s;
}

.key-white.is-colored {
  background: var(--key-color);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}

.key-name {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(34px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 0.95rem;
  white-space: nowrap;
}

.key-white.is-colored .key-name {
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-text);
}

.key-white.is-dim {
  opacity: 0.28;
  pointer-events: none;
}

.key-white:active,
.key-white.is-pressed {
  transform: translateY(3px);
  box-shadow: inset 0 -2px 0 #dcdaf0;
}

.key-black {
  position: absolute;
  top: 8px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 9%;
  height: 58%;
  padding: 0 0 6px;
  border-radius: 0 0 8px 8px;
  background: var(--color-black-key);
  color: #fff;
  font-size: 0.58rem;
  letter-spacing: -1px;
  white-space: nowrap;
  box-shadow: inset 0 -5px 0 #111;
}

.key-black.is-dim {
  opacity: 0.35;
  pointer-events: none;
}

.key-black:active,
.key-black.is-pressed {
  transform: translateY(2px);
}

.key-white:focus-visible,
.key-black:focus-visible {
  outline: 3px solid var(--color-yellow);
  outline-offset: -3px;
}

/* まちがえた とき、こたえの けんばんを ひからせる */
.is-glow {
  animation: key-glow 0.5s ease-in-out 3;
}

@keyframes key-glow {
  50% {
    box-shadow: 0 0 0 6px var(--color-yellow), 0 0 24px var(--color-yellow);
  }
}

/* こたえた あとは、つぎの もんだいまで おせない */
.keyboard.is-locked .key-white,
.keyboard.is-locked .key-black {
  pointer-events: none;
}

.play-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* ===== けっかの がめん ===== */
.clear-dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 40, 0.6);
  animation: fade-in 0.25s;
}

.clear-dialog[hidden] {
  display: none;
}

.clear-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 20px;
  text-align: center;
  animation: pop-in 0.4s cubic-bezier(0.3, 1.5, 0.6, 1);
}

.clear-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--color-main);
  word-break: keep-all;
}

.result-text {
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-medium);
  background: #f1effb;
  font-size: 1.05rem;
}

.flowers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 300px;
}

.flowers svg {
  display: block;
  width: 100%;
  height: auto;
}

.clear-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* きょうしつへの ボタン（こどもが おしたく なる みため） */
.studio-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin-top: 4px;
  padding: 14px 16px;
  border: 3px dashed #c9c5ee;
  border-radius: var(--radius-medium);
  background: #faf9ff;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.studio-button:hover {
  border-color: var(--color-accent);
  background: #eef9ff;
}

.studio-button-main {
  font-size: 1.05rem;
  color: var(--color-text);
}

.studio-button-sub {
  font-size: 0.85rem;
  color: var(--color-accent-dark);
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.7); }
}

/* ===== スマホ ===== */
/*
  スクロール しないで 1がめんに おさまるように つめる。
  --spare（たかさの よゆう。common.css で きめている）が おおきいほど、ゆったり みせる。
*/
@media (max-width: 600px) {
  .page--game .setup {
    gap: calc(10px + var(--spare) * 12 / 190);
  }

  .setting-title {
    margin-bottom: calc(6px + var(--spare) * 4 / 190);
  }

  .mode-list {
    gap: calc(6px + var(--spare) * 4 / 190);
  }

  .mode-choice {
    padding: calc(6px + var(--spare) * 6 / 190) 10px;
    font-size: calc(0.98rem + var(--spare) * 1.6 / 190);
  }

  .mode-icon {
    font-size: calc(1.25rem + var(--spare) * 4 / 190);
  }

  .level-choice {
    min-height: calc(56px + var(--spare) * 14 / 190);
    font-size: 0.85rem;
  }

  .play {
    gap: calc(8px + var(--spare) * 6 / 190);
  }

  .hud-item {
    padding: 2px 4px 4px;
  }

  .hud-value {
    font-size: calc(1.2rem + var(--spare) * 3 / 190);
  }

  .ask-main {
    font-size: calc(1.3rem + var(--spare) * 4 / 190);
  }

  .keyboard-wrap {
    max-height: calc(240px + var(--spare) * 100 / 190);
  }
}

/* たかさが ひくい ときは、むずかしさの せつめいを かくす */
@media (max-height: 700px) {
  .level-choice small {
    display: none;
  }

  .mode-text small {
    font-size: 0.72rem;
  }
}

/* うごきを へらす せっていの ひと */
@media (prefers-reduced-motion: reduce) {
  .clear-box,
  .clear-dialog {
    animation: none;
  }
}
