/* =========================================
   LOCAL GAME STYLES: Find The Key — Pachelbel's Canon In ?
   Builds on top of ../../shared/global.css
   ========================================= */

:root {
  --game-purple:        #a78bfa;
  --game-purple-shadow: #7c3aed;
  --game-pink:          #f472b6;
  --game-pink-shadow:   #db2777;

  --key-selected-bg:     rgba(99,102,241,0.22);
  --key-selected-border: #6366f1;
  --key-correct-bg:      #22c55e;
  --key-correct-shadow:  #15803d;
  --key-incorrect-bg:    #ef4444;
  --key-incorrect-shadow:#b91c1c;

  --pulseColor: #4da3ff;
  --pulseRGBA:  rgba(77,163,255,0.28);
}

/* ─── Layout Panels ─── */
.statusPanel { border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }

.controlsPanel,
.answerPanel,
.analysisCard {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 10px 10px 14px;
  box-shadow: var(--shadow-soft);
}
body.light-theme .controlsPanel,
body.light-theme .answerPanel,
body.light-theme .analysisCard { border-color: rgba(0,0,0,0.05); }

/* ─── Game Title ─── */
.gameMainTitle {
  text-align: center;
  font-size: max(14pt, calc((22px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 900; color: var(--text-main); margin: 0; padding: 0 12px;
}
.modalGameTitle {
  text-align: center;
  font-size: max(14pt, calc((22px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 900; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px;
}
.modalGameSubtitle {
  text-align: center;
  font-size: max(11pt, calc((17px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 800; color: var(--text-muted); margin-bottom: 10px; letter-spacing: 0.2px;
}

/* ─── Status Area ─── */
.statusRow { display: flex; flex-direction: column; align-items: center; }
.statusText {
  text-align: center; width: 100%; background: var(--bg-base);
  padding: 12px 16px 14px; border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.05);
}
body.light-theme .statusText { border-color: rgba(0,0,0,0.05); }

.roundBadge {
  display: inline-block; font-size: 11px; font-weight: 800;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px;
  background: var(--bg-elevated); border-radius: 20px; padding: 3px 12px;
  margin-bottom: 6px;
}

.phaseTitle  { font-size: max(14pt, calc((22px + var(--font-adjust)) * var(--font-scale))); font-weight: 900; color: var(--text-main); margin-bottom: 6px; }
.feedbackLine { font-size: max(11pt, calc((16px + var(--font-adjust)) * var(--font-scale))); color: var(--text-muted); min-height: 24px; font-weight: 500; }
.feedbackLine strong {
  color: #fff; font-weight: 800;
  background: var(--accent); padding: 2px 6px; border-radius: 6px;
}

/* ─── Controls Grid ─── */
.actionsGrid {
  display: flex; gap: 6px; margin-bottom: 12px; width: 100%;
}
.actionsGrid .icon-btn { flex: 0 0 52px; height: 52px; padding: 0; font-size: 22px; }
.actionsGrid .flex-text-btn { flex: 1 1 0; padding: 0 4px; font-size: 12pt; white-space: nowrap; }
.mainActionRow { display: flex; gap: 6px; }

/* ─── Game Buttons ─── */
.btn-purple {
  background: var(--game-purple); color: #fff;
  border: 2px solid var(--game-purple-shadow);
  box-shadow: 0 4px 0 var(--game-purple-shadow);
}
.btn-purple.playing {
  background: var(--game-purple-shadow);
  box-shadow: 0 2px 0 var(--game-purple-shadow);
}
.btn-pink {
  background: var(--game-pink); color: #fff;
  border: 2px solid var(--game-pink-shadow);
  box-shadow: 0 4px 0 var(--game-pink-shadow);
}

.submitBtn {
  background: var(--bg-elevated); color: var(--text-main);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 4px 0 rgba(0,0,0,0.35);
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.submitBtn:disabled { opacity: 0.45; cursor: not-allowed; }
.submitBtn.submitReady {
  background: var(--accent);
  color: #0f172a;
  border-color: #0284c7;
  box-shadow: 0 4px 0 #0284c7;
  animation: submitPulse 1.1s ease-in-out infinite;
}
.submitBtn.submitReady:active { box-shadow: 0 0px 0 #0284c7; transform: translateY(4px); }

.next-btn {
  background: var(--bg-base); color: var(--text-main);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 4px 0 var(--bg-elevated);
  flex: 1;
}
.next-btn:disabled {
  opacity: 0.5; background: var(--bg-surface); color: var(--text-muted);
  border-color: var(--bg-elevated); box-shadow: 0 4px 0 var(--bg-elevated);
  cursor: not-allowed;
}
.nextReady {
  background: var(--next-orange) !important; color: #fff !important;
  border-color: var(--next-shadow) !important;
  box-shadow: 0 4px 0 var(--next-shadow) !important;
  --ringColor: rgba(255,127,42,0.4);
  animation: ringPulse 1.5s ease-in-out infinite;
}
.nextReady:active:not(:disabled) { box-shadow: 0 0px 0 var(--next-shadow) !important; transform: translateY(4px); }

.default-btn {
  background: var(--bg-elevated); color: var(--text-main);
  border: 2px solid #1e293b;
  box-shadow: 0 4px 0 #1e293b;
}
.default-btn:active:not(:disabled) { box-shadow: 0 0px 0 #1e293b; transform: translateY(4px); }

.secondary-btn {
  background: var(--bg-elevated); color: #fff;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 4px 0 var(--bg-elevated);
}
.secondary-btn:active:not(:disabled) { box-shadow: 0 0px 0 var(--bg-elevated); transform: translateY(4px); }

/* ─── Pulse Animations ─── */
@keyframes beginPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
  55%  { box-shadow: 0 0 0 12px var(--pulseRGBA); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.pulse { animation: beginPulse 1.25s ease-in-out infinite; }

/* btn-purple keeps its bottom shadow while pulsing */
@keyframes purpleBtnPulse {
  0%   { box-shadow: 0 4px 0 var(--game-purple-shadow); }
  55%  { box-shadow: 0 4px 0 var(--game-purple-shadow), 0 0 0 10px var(--pulseRGBA); }
  100% { box-shadow: 0 4px 0 var(--game-purple-shadow); }
}
.btn-purple.pulse { animation: purpleBtnPulse 1.25s ease-in-out infinite; }

@keyframes submitPulse {
  0%   { box-shadow: 0 4px 0 #0284c7; }
  55%  { box-shadow: 0 4px 0 #0284c7, 0 0 0 10px rgba(56,189,248,0.25); }
  100% { box-shadow: 0 4px 0 #0284c7; }
}

/* ─── Answer Key Grid ─── */
.answerPanel { padding: 10px; }

.keyGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.keyChoiceBtn {
  background: var(--bg-elevated); color: var(--text-main);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: max(11pt, calc((15px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 700;
  cursor: pointer; text-align: center;
  flex: 0 0 auto;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  font-family: var(--font-main);
}
.keyChoiceBtn:active:not(:disabled) { transform: scale(0.97); }
.keyChoiceBtn:disabled { cursor: not-allowed; }

.playSelectedScaleBtn {
  margin-top: 10px;
}

.keyChoiceBtn.selected {
  background: var(--key-selected-bg);
  border-color: var(--key-selected-border);
  color: #c7d2fe;
}
.keyChoiceBtn.correct {
  background: var(--key-correct-bg) !important;
  border-color: var(--key-correct-bg) !important;
  color: #052e16 !important;
  box-shadow: 0 3px 0 var(--key-correct-shadow);
}
.keyChoiceBtn.incorrect {
  background: var(--key-incorrect-bg) !important;
  border-color: var(--key-incorrect-bg) !important;
  color: #450a0a !important;
  box-shadow: 0 3px 0 var(--key-incorrect-shadow);
}

/* ─── Score / Analysis ─── */
.analysis { padding: 0; background: transparent; border: none; box-shadow: none; margin-top: 14px; }
.analysisGrid { display: flex; flex-direction: column; gap: 12px; }
.analysisCard { max-width: 100%; }
.analysisLabel { font-size: 18px; font-weight: 900; color: var(--text-main); margin: 12px 0 4px; text-align: center; }
.scoreMeta { text-align: center; font-size: 14px; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; }
.inside-modal { background: transparent; border: none; box-shadow: none; padding: 0; }
.scoreActions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.scoreGrid { display: grid; gap: 8px; }
.scoreGridVertical { grid-template-columns: 1fr; }
.scoreItem {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg-base);
  border-radius: var(--radius-sm); border: 2px solid var(--bg-elevated);
}
.scoreK { font-size: 13px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.scoreV { font-size: 20px; font-weight: 900; }
.text-correct   { color: var(--info-teal); }
.text-incorrect { color: var(--danger); }
.text-accent    { color: var(--accent); }

/* ─── Score Modal Big Result ─── */
.roundResultBig {
  font-size: 3rem; font-weight: 900; color: var(--accent);
  text-align: center; margin: 10px 0 4px;
}
.roundRating {
  font-size: 1.05rem; font-weight: 700; color: var(--text-main);
  text-align: center; margin-bottom: 6px;
}

/* ─── Choose Keys Modal ─── */
.settingsHint {
  font-size: max(10pt, calc((13px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 700; color: var(--text-muted); margin-bottom: 10px;
  text-align: center;
}

.quickSelectRow {
  display: flex; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 12px;
  justify-content: center;
}
.quickSelectBtn {
  background: none; border: 1px solid var(--bg-elevated);
  color: var(--accent);
  font-size: max(9pt, calc((12px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 700;
  border-radius: 20px; padding: 4px 12px; cursor: pointer;
  font-family: var(--font-main);
  transition: background 0.12s, color 0.12s;
}
.quickSelectBtn:hover { background: var(--bg-elevated); color: var(--text-main); }

.keysToggleGrid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.keyToggleBtn {
  background: var(--bg-elevated); border: 2px solid transparent;
  border-radius: var(--radius-sm); padding: 11px 8px;
  font-size: max(10pt, calc((14px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 700; color: var(--text-muted);
  text-align: center; cursor: pointer; font-family: var(--font-main);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.keyToggleBtn.selected {
  background: var(--key-selected-bg);
  border-color: var(--key-selected-border);
  color: #c7d2fe;
}
.selectionWarning {
  margin-top: 8px; text-align: center;
  font-size: max(10pt, calc((13px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 800; color: var(--danger);
}

/* ─── Callout Hint (Intro) ─── */
.calloutHint {
  background: rgba(15,23,42,0.45);
  border-left: 3px solid var(--accent);
  padding: 12px 14px; border-radius: 0 10px 10px 0;
  margin: 12px 0;
}
.calloutHint strong { color: var(--accent); }
body.light-theme .calloutHint { background: rgba(226,232,240,0.6); }

/* ─── Help Modal (details/summary) ─── */
.helpSection {
  margin: 10px 0; border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm); overflow: hidden;
}
.helpSectionTitle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  font-size: max(10pt, calc((14px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 800;
  color: var(--text-main); cursor: pointer; list-style: none;
  background: var(--bg-elevated);
  user-select: none;
}
.helpSectionTitle::-webkit-details-marker { display: none; }
.helpSectionTitle::marker { content: ""; }
.helpSectionTitle::after { content: "▾"; font-size: 14px; color: var(--text-muted); }
details[open] > .helpSectionTitle::after { content: "▴"; }

.helpSectionBody {
  padding: 12px 14px; background: var(--bg-base);
  font-size: max(10pt, calc((14px + var(--font-adjust)) * var(--font-scale)));
  line-height: 1.6; color: var(--text-muted);
}
.helpSectionBody p + p { margin-top: 10px; }

/* ─── Modal Settings ─── */
.settingsGrid { margin: 14px 0; }
.settingsTitle { font-size: 13px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px; text-align: center; }
.settingsHintInline { text-transform: none; font-weight: 600; opacity: 0.8; letter-spacing: 0; }

/* ─── Inputs ─── */
input:not([type=checkbox]):not([type=radio]) {
  width: 100%; height: 50px;
  background: var(--bg-base); border: 2px solid var(--bg-elevated);
  color: var(--text-main); border-radius: var(--radius-sm);
  padding: 0 16px; font-family: var(--font-main);
  font-size: 15px; font-weight: 700; outline: none;
  -webkit-appearance: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
input:not([type=checkbox]):not([type=radio]):focus { border-color: var(--accent); }

/* ─── Attempt Log ─── */
.attemptLog { margin-top: 12px; }

.attemptLogHeader {
  font-size: max(9pt, calc((12px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 800; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px; text-align: center;
}

.attemptEntry {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; margin-bottom: 4px;
  background: var(--bg-base); border-radius: var(--radius-sm);
  border: 2px solid var(--bg-elevated);
  font-size: max(10pt, calc((13px + var(--font-adjust)) * var(--font-scale)));
  font-weight: 700;
}
.attemptNum  { color: var(--text-muted); min-width: 22px; text-align: right; flex-shrink: 0; }
.attemptIcon { flex-shrink: 0; font-size: 1em; }
.attemptKey  { color: var(--text-main); flex: 1 1 0; min-width: 0; }
.attemptArrow { color: var(--text-muted); flex-shrink: 0; }
.attemptChosen { color: var(--text-muted); flex-shrink: 0; font-style: italic; }
.attemptEntry.attemptIncorrect .attemptKey { color: var(--danger); }

/* Piano-key hint: brief blue glow on the answer button, does NOT select it */
.keyChoiceBtn.piano-highlight {
  background: rgba(59, 130, 246, 0.18) !important;
  border-color: #3b82f6 !important;
  color: #93c5fd !important;
}

/* ─── Virtual Piano ─── */
.pianoSection {
  display: flex; justify-content: center;
  padding: 4px 0 2px;
}
.pianoMount {
  width: 100%;
  max-width: 600px;
}
.pianoMount svg {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
}
/* Key press animation */
@keyframes pkPressWhite {
  0%   { fill: #93c5fd; }
  100% { fill: #ffffff; }
}
@keyframes pkPressBlack {
  0%   { fill: #3b82f6; }
  100% { fill: #1e293b; }
}
