:root {
  color-scheme: light;
  --sky-deep: #173454;
  --sky-mid: #2873aa;
  --panel: rgba(17, 49, 79, 0.94);
  --panel-2: rgba(24, 66, 101, 0.92);
  --cream: #fffaf0;
  --cream-2: #fff0cd;
  --text: #f8fbff;
  --dark-text: #173454;
  --muted: #bcd5e8;
  --border: rgba(246, 196, 105, 0.58);
  --accent: #f1a72f;
  --accent-2: #73dff7;
  --danger: #ff6670;
  --ok: #84df9a;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  color: var(--text);
  background: #78cfff url('assets/skins/sky/backgrounds/floating-kingdom.jpg') center/cover fixed no-repeat;
}
button, select, input { font: inherit; }
button, select, input[type=number] {
  min-height: 42px;
  border: 1px solid rgba(245, 201, 120, 0.62);
  background: #163d62;
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .75rem;
}
button { cursor: pointer; font-weight: 800; }
button:hover { border-color: #ffd88b; }
button.primary {
  background: linear-gradient(#ffc967, #e89528);
  border-color: #ffe1a6;
  color: #39250d;
  box-shadow: inset 0 1px rgba(255,255,255,.55);
}
button.ghost { background: rgba(11, 42, 70, .35); }

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }
.menu-screen {
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  background: linear-gradient(rgba(34, 111, 168, .16), rgba(15, 54, 91, .36));
}
.menu-card, .settings-card {
  width: min(820px, 100%);
  background: linear-gradient(180deg, rgba(24, 67, 102, .95), rgba(11, 42, 70, .95));
  border: 2px solid rgba(247, 202, 118, .72);
  border-radius: 20px;
  box-shadow: 0 22px 75px rgba(19, 68, 105, .42), inset 0 1px rgba(255,255,255,.14);
  padding: 28px;
  backdrop-filter: blur(8px);
}
.hero-card { text-align: center; max-width: 700px; }
.eyebrow { font-size: .72rem; letter-spacing: .16em; color: #ffe09b; font-weight: 900; }
.hero-card h1, .settings-card h2, .overlay-card h2 {
  margin: .35rem 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: -.04em;
  text-shadow: 0 2px 0 rgba(0,0,0,.16);
}
.settings-card h2, .overlay-card h2 { font-size: 2rem; }
.subtitle { color: #d5e7f5; max-width: 600px; margin: 8px auto 22px; line-height: 1.5; }
.menu-actions, .overlay-actions, .form-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-actions button { min-width: 140px; }
.menu-summary {
  margin: 18px auto 24px;
  border: 1px solid rgba(255, 221, 153, .38);
  background: rgba(8, 38, 65, .58);
  border-radius: 12px;
  padding: 12px;
  color: #e2eff8;
}
.key-hint, .footnote, .game-hint { color: var(--muted); font-size: .84rem; }
.key-hint { margin: 22px 0 0; }
.screen-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.settings-card { max-width: 900px; }
fieldset {
  border: 1px solid rgba(204, 230, 246, .28);
  border-radius: 14px;
  padding: 10px 16px 14px;
  margin: 0 0 16px;
  background: rgba(8, 39, 66, .44);
}
legend { padding: 0 8px; color: #ffe09b; font-weight: 900; letter-spacing: .04em; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(170px,1fr) minmax(200px,320px);
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(174, 215, 239, .18);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row.unavailable { opacity: .42; }
.setting-row.unavailable .switch { cursor: not-allowed; }
.setting-row.unavailable .switch span { filter: saturate(.35); }
.setting-row label:first-child, .setting-row > span { font-weight: 700; }
.setting-row select, .setting-row input[type=number] { width: 100%; }
.toggle-row { grid-template-columns: 1fr auto; }
.read-only-row strong { justify-self: end; color: #fff1c7; }
.switch { display: inline-flex; align-items: center; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  width: 50px; height: 28px; border-radius: 999px;
  background: #35556f; border: 1px solid #64829a; position: relative; transition: .16s;
}
.switch span:after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  left: 3px; top: 3px; background: #e6f1f8; transition: .16s;
}
.switch input:checked + span { background: #d98926; border-color: #ffca67; }
.switch input:checked + span:after { left: 25px; background: #fff; }
.subsettings { padding: 8px 8px 10px 18px; border-left: 2px solid #73b9df; margin: 0 0 4px 8px; }
.subsettings.hidden { display: none; }
.range-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-grid label { display: grid; grid-template-columns: 1fr 100px; gap: 10px; align-items: center; color: #d2e5f1; }
.volume-row { grid-template-columns: minmax(170px,1fr) minmax(180px,1fr) 54px; }
.volume-row output { text-align: right; color: #fff1c7; }
.settings-message { min-height: 1.2em; color: #ffd0d3; font-weight: 700; margin-bottom: 8px; }
.form-actions { justify-content: flex-end; margin-top: 22px; }

.game-screen.active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  background: #86d6ff;
  overflow: hidden;
}
.hud {
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1180px, calc(100% - 18px));
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  pointer-events: none;
}
.hud > div {
  background: linear-gradient(180deg, rgba(21, 60, 96, .95), rgba(12, 44, 73, .94));
  border: 1px solid rgba(255, 213, 132, .72);
  border-radius: 11px;
  padding: 7px 8px;
  text-align: center;
  box-shadow: inset 0 1px rgba(255,255,255,.13), 0 2px 7px rgba(27,77,112,.22);
  backdrop-filter: blur(5px);
}
.hud span { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: #bcdcf0; }
.hud strong { font-size: 1rem; color: #fffaf0; }
.canvas-shell { width: 100vw; height: 100vh; display: flex; }
.canvas-shell canvas { width: 100%; height: 100%; display: block; background: #8dd9ff; }
.touch-keyboard-input {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  font-size: 16px;
  caret-color: transparent;
}
.game-hint {
  position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(19, 59, 91, .72); color: #eff9ff; padding: 5px 11px; border-radius: 8px; white-space: nowrap;
  border: 1px solid rgba(255, 226, 167, .35);
}

.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(13, 48, 77, .62);
  display: flex; align-items: center; justify-content: center; padding: 18px; backdrop-filter: blur(5px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: min(520px,100%);
  background: linear-gradient(180deg, #194b76, #0e3558);
  border: 2px solid rgba(255, 210, 125, .7);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 70px rgba(13, 48, 77, .5);
}
.gameover-grid, .stat-summary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin: 18px 0; }
.gameover-grid > div, .stat-summary-grid > div {
  background: rgba(8, 42, 70, .62); border: 1px solid rgba(196, 225, 242, .27); border-radius: 10px; padding: 12px;
}
.gameover-grid span, .stat-summary-grid span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.gameover-grid strong, .stat-summary-grid strong { font-size: 1.25rem; }
.stats-card { max-width: 1000px; }
.table-wrap { overflow-x: auto; border: 1px solid rgba(198, 225, 241, .28); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(190, 219, 236, .2); }
th { color: #ffe09b; font-size: .76rem; text-transform: uppercase; background: rgba(8, 42, 70, .7); }
td { color: #ecf6fc; }
.footnote { line-height: 1.5; }
.hidden { display: none !important; }

@media (max-width: 700px) {
  .menu-screen { padding: 14px 10px; }
  .menu-card, .settings-card { padding: 18px; border-radius: 12px; }
  .setting-row { grid-template-columns: 1fr; gap: 7px; }
  .toggle-row { grid-template-columns: 1fr auto; }
  .read-only-row { grid-template-columns: 1fr auto; }
  .range-grid { grid-template-columns: 1fr; }
  .range-grid label { grid-template-columns: 1fr 90px; }
  .volume-row { grid-template-columns: 1fr 1fr 50px; }
  .hud { grid-template-columns: repeat(4,1fr); top: 5px; }
  .hud > div { padding: 4px; }
  .hud span { font-size: .56rem; }
  .hud strong { font-size: .85rem; }
  .game-hint { display: none; }
  .gameover-grid, .stat-summary-grid { grid-template-columns: repeat(2,1fr); }
}

/* Main-v4.2 player, preset, and data-management additions */
input[type=text] {
  min-height: 42px;
  border: 1px solid rgba(245, 201, 120, 0.62);
  background: #163d62;
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .75rem;
  width: 100%;
}
button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
.active-player-banner {
  display: inline-block;
  margin: 0 auto 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(8, 38, 65, .66);
  border: 1px solid rgba(255, 221, 153, .38);
  color: #dceefa;
}
.active-player-banner strong { color: #fff1c7; }
.settings-actions-top {
  justify-content: flex-end;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(174, 215, 239, .18);
}
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 10px 0 4px;
}
.field-note {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}
.section-note { margin: 2px 0 8px; }
.danger-button { border-color: rgba(255, 102, 112, .58); }
.stats-player-line { color: var(--muted); margin-top: 3px; }
.stats-player-line strong { color: #fff1c7; }

@media (max-width: 700px) {
  .settings-actions-top, .inline-actions { justify-content: stretch; }
  .settings-actions-top button, .inline-actions button { flex: 1 1 150px; }
}

/* Main-v6.1 Letter Learner curriculum */
.learner-settings-disabled { opacity: .48; }
.subsettings.unavailable { opacity: .42; }

.letter-learner-panel {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 38px;
  transform: translateX(-50%);
  width: min(980px, calc(100% - 24px));
  background: linear-gradient(180deg, rgba(15, 52, 84, .91), rgba(8, 35, 59, .94));
  border: 1px solid rgba(255, 219, 148, .72);
  border-radius: 16px;
  box-shadow: 0 12px 38px rgba(9, 38, 63, .38), inset 0 1px rgba(255,255,255,.12);
  padding: 10px 12px 12px;
  backdrop-filter: blur(7px);
}
.letter-learner-panel[hidden] { display: none; }
.learner-status-row {
  display: grid;
  grid-template-columns: minmax(220px,1.2fr) minmax(150px,.65fr) auto;
  gap: 12px;
  align-items: center;
}
.learner-lesson-title { font-weight: 900; color: #fff1bd; font-size: 1rem; }
.learner-status-text { margin-top: 2px; color: #cfe6f5; font-size: .8rem; line-height: 1.3; }
.learner-progress-wrap { display: grid; grid-template-columns: 42px 1fr; gap: 5px 8px; align-items: center; }
.learner-progress-caption { grid-column: 1 / -1; color: #a9cbe0; font-size: .66rem; font-weight: 800; letter-spacing: .02em; }
.learner-progress-wrap > span { color: #fff1bd; font-weight: 900; text-align: right; }
.learner-progress-track { height: 9px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.learner-progress-track > div { height: 100%; width: 0; background: linear-gradient(90deg,#75dcff,#ffd56f); border-radius: inherit; transition: width .2s ease; }
.learner-actions { display: flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.learner-actions button { min-height: 34px; padding: .35rem .55rem; font-size: .78rem; }

.learner-key-help {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  border-top: 1px solid rgba(180,218,240,.18);
  padding-top: 8px;
}
.learner-key-help[hidden] { display: none; }
.learner-target-card {
  min-height: 115px;
  border-radius: 13px;
  border: 1px solid rgba(255, 216, 139, .52);
  background: rgba(5, 31, 53, .66);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 7px;
}
.learner-target-card span { color: #a9cbe0; font-size: .64rem; letter-spacing: .16em; font-weight: 900; }
.learner-target-card strong { font-size: 2.4rem; color: #fff4c7; line-height: 1.05; margin: 2px 0 5px; }
.learner-target-card small { color: #d6ebf7; font-size: .68rem; line-height: 1.25; }
.keyboard-guide-wrap { position: relative; min-height: 132px; }
.keyboard-diagram { position: relative; z-index: 1; display: grid; gap: 5px; padding: 3px 5px 5px; }
.keyboard-row { display: flex; gap: 5px; justify-content: center; }
.keyboard-row-2 { padding-left: 20px; padding-right: 8px; }
.keyboard-row-3 { padding-left: 52px; padding-right: 28px; }
.keyboard-key {
  position: relative;
  flex: 1 1 0;
  max-width: 68px;
  min-width: 38px;
  height: 38px;
  border-radius: 7px;
  border: 1px solid rgba(178, 214, 236, .42);
  background: linear-gradient(180deg, rgba(39,80,112,.86), rgba(17,55,84,.91));
  box-shadow: inset 0 1px rgba(255,255,255,.09), 0 2px 2px rgba(0,0,0,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s, border-color .1s, background .1s, box-shadow .1s;
}
.keyboard-key .key-output { color: #eaf6fc; font-weight: 900; font-size: 1rem; }
.keyboard-key .key-physical { position: absolute; left: 4px; top: 2px; color: #91b7ce; font-size: .5rem; font-weight: 800; }
.keyboard-key.home-key:after { content:''; position:absolute; bottom:3px; left:50%; width:12px; height:2px; transform:translateX(-50%); border-radius:3px; background:rgba(255,232,178,.65); }
.keyboard-key.non-letter-key { opacity: .42; }
.keyboard-key.learned { border-color: rgba(129, 222, 159, .48); }
.keyboard-key.lesson-key { box-shadow: inset 0 0 0 1px rgba(255,217,124,.34); }
.keyboard-key.active {
  transform: translateY(-2px) scale(1.05);
  border-color: #fff0a8;
  background: linear-gradient(180deg, #f9c75e, #df8f2e);
  box-shadow: 0 0 0 3px rgba(255,217,118,.18), 0 0 18px rgba(255,204,92,.55);
}
.keyboard-key.active .key-output { color: #34250d; }
.keyboard-key.active .key-physical { color: rgba(52,37,13,.62); }
.hand-guide { position:absolute; z-index:2; inset:0; pointer-events:none; overflow:visible; }
.hand-guide[hidden] { display:none; }
.hand-guide svg { width:100%; height:100%; overflow:visible; }
.hand-palm { fill: rgba(215,238,250,.08); stroke: rgba(215,238,250,.16); stroke-width: 2; }
.hand-finger { fill:none; stroke:rgba(216,238,250,.20); stroke-width:14; stroke-linecap:round; }
.hand-finger.active { stroke:rgba(255,212,103,.72); stroke-width:18; filter:drop-shadow(0 0 6px rgba(255,204,92,.45)); }
.finger-travel { fill:none; stroke:rgba(255,244,192,.92); stroke-width:3; stroke-dasharray:5 4; marker-end:none; }

@media (max-width: 760px) {
  .letter-learner-panel { bottom: 8px; width: calc(100% - 10px); padding: 7px; }
  .learner-status-row { grid-template-columns: 1fr auto; }
  .learner-progress-wrap { grid-column: 1 / -1; order: 3; }
  .learner-actions { grid-column: 2; grid-row: 1 / span 2; max-width: 150px; }
  .learner-key-help { grid-template-columns: 78px 1fr; gap: 6px; }
  .learner-target-card { min-height: 100px; }
  .keyboard-key { min-width: 24px; height: 31px; border-radius: 5px; }
  .keyboard-key .key-output { font-size: .8rem; }
  .keyboard-key .key-physical { display:none; }
  .keyboard-row { gap: 3px; }
  .keyboard-row-2 { padding-left: 10px; }
  .keyboard-row-3 { padding-left: 24px; padding-right: 12px; }
}

/* v6.2 learning/content and analytics refinements */
.settings-subsection { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid rgba(180,218,240,.18); }
.settings-subsection h3, .stats-card h3 { margin: .7rem 0 .45rem; color: #fff1bd; }
.stats-language-tabs { display:flex; gap:.45rem; flex-wrap:wrap; margin:.35rem 0 .65rem; }
.stats-lang-button.active { border-color: rgba(255,221,137,.8); background: rgba(255,214,111,.16); }
.lesson-detail-card { margin-top:.8rem; padding:.75rem; border:1px solid rgba(180,218,240,.2); border-radius:12px; background:rgba(5,31,53,.38); }
.lesson-detail-card h4 { margin:.1rem 0 .6rem; color:#fff1bd; }
.lesson-management { display:flex; gap:.45rem; flex-wrap:wrap; margin-bottom:.65rem; }
button.danger { border-color:rgba(255,125,125,.55); color:#ffd0d0; background:rgba(120,25,25,.28); }
#game-lesson-select { min-width: 230px; max-width: 360px; min-height:34px; }
@media (max-width:760px) { #game-lesson-select { min-width:150px; max-width:210px; } }
