/* Shared start-screen chrome — greeting, player switch, ○, parent switcher, install hint, site footer.
   Browser: sibling/hub + credits on the game home screen and in parent mode.
   Installed PWA: that footer in parent mode only. The install hint is hidden.
   Loaded by Flaggen / Mathe / English. Do not Cache Storage this file while game SWs
   wipe all origin caches on activate. */

/* ---------- Greeting + player switch ---------- */
.kg-greeting,
.greeting {
  font-family: 'Baloo 2', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted, #888);
  text-align: center;
  line-height: 1.35;
  margin-bottom: 28px;
  width: 100%;
  padding: 0 12px;
  position: relative;
}
/* Name prompt sits above play controls on first visit — keep the gap tight */
.kg-greeting:has(.name-form:not([hidden])),
.greeting:has(.name-form:not([hidden])) {
  margin-bottom: 16px;
}
.kg-greeting span,
.greeting span { color: var(--purple, #c77dff); }

.player-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 2px;
  padding: 2px 10px 2px 12px;
  border: 2px solid rgba(199, 125, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--purple, #c77dff);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  vertical-align: baseline;
}
.player-name-btn:active { transform: scale(0.96); }
.player-name-caret {
  font-size: 0.75em;
  opacity: 0.7;
  line-height: 1;
}

.player-menu {
  position: absolute;
  left: 50%;
  top: calc(100% - 8px);
  transform: translateX(-50%);
  z-index: 20;
  width: min(260px, calc(100% - 24px));
  padding: 8px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(77, 150, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.player-menu[hidden] { display: none; }
.player-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text, #222);
  font-family: 'Baloo 2', cursive;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.player-menu-item:hover,
.player-menu-item:focus-visible {
  background: rgba(77, 150, 255, 0.12);
}
.player-menu-add {
  color: var(--primary, #4d96ff);
}
.player-menu-add[hidden] { display: none; }
/* Divider above Add player only when other players are listed */
.player-menu.has-others .player-menu-add {
  order: 1;
  color: var(--muted, #888);
  font-size: 0.9rem;
  font-weight: 600;
  border-top: 1px solid #eee;
  border-radius: 0 0 12px 12px;
  margin-top: 2px;
  padding: 8px 12px;
}
.player-menu.has-others .player-menu-add:hover,
.player-menu.has-others .player-menu-add:focus-visible {
  background: transparent;
  color: var(--text, #222);
}
.player-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  background: #fff9f0;
}
.player-swatch[data-color="cream"] { background: #fff9f0; }
.player-swatch[data-color="sky"] { background: #eef6ff; }
.player-swatch[data-color="mint"] { background: #eefaf3; }
.player-swatch[data-color="lilac"] { background: #f6f0ff; }
.player-swatch[data-color="peach"] { background: #fff3ea; }
.player-swatch[data-color="rose"] { background: #fff0f3; }

.name-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.name-form[hidden] { display: none; }
.name-prompt {
  font: inherit;
  color: inherit;
  text-align: center;
}
.name-form-row {
  position: relative;
  width: 100%;
  max-width: 280px;
}
.name-input {
  width: 100%;
  min-width: 0;
  padding: 10px 44px;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  font-family: 'Baloo 2', cursive;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #222);
  background: white;
  text-align: center;
  cursor: text;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
}
.name-input:focus { outline: none; border-color: var(--primary, #4d96ff); }
.name-save-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--accent, #6bcb77);
  color: white;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.name-save-btn:disabled {
  visibility: hidden;
  pointer-events: none;
}
.name-save-btn:not(:disabled):active { transform: translateY(-50%) scale(0.94); }
.name-cancel-btn {
  margin-top: 4px;
  padding: 8px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted, #888);
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.name-cancel-btn[hidden] { display: none; }
.name-cancel-btn:active { color: var(--text, #222); }
.name-form-error {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary, #ff6b6b);
  text-align: center;
}
.name-form-error[hidden] { display: none; }

/* ---------- ○ parent control ---------- */
.kg-admin-link,
.admin-link,
.parents-link {
  margin-top: 24px;
  font-size: 1.1rem;
  line-height: 1;
  color: #ddd;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  background: none;
  border: none;
  padding: 8px;
  font-family: inherit;
  display: inline-block;
  text-align: center;
}
.kg-admin-link:hover,
.admin-link:hover,
.parents-link:hover { color: var(--muted, #888); }

/* ---------- Install / add-to-home hint (mobile browser, not installed PWA) ---------- */
.kg-install-prompt {
  width: 100%;
  max-width: 420px;
  margin-top: 16px;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: var(--btn-border, 2px) solid var(--btn-face-edge, rgba(0, 0, 0, 0.08));
  border-radius: var(--btn-radius-sm, 14px);
  padding: 12px 16px;
  text-align: center;
  background: var(--btn-face, #fff);
  cursor: pointer;
  box-shadow:
    0 var(--btn-depth-sm, 2px) 0 var(--btn-face-shadow, transparent),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 2px 0 var(--btn-highlight, rgba(255, 255, 255, 0.45));
  font-family: 'Baloo 2', cursive;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.kg-install-prompt[hidden] { display: none !important; }
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .kg-install-prompt { display: none !important; }
}
.kg-install-prompt-text {
  color: var(--muted, #888);
  font-size: 0.85rem;
  line-height: 1.35;
}
.kg-install-prompt-action {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--blue, var(--primary, #4d96ff));
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.kg-install-prompt-action[hidden] { display: none !important; }
.kg-install-prompt:active {
  transform: translateY(var(--btn-depth-sm, 2px));
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.12), inset 0 1px 0 var(--btn-highlight, rgba(255, 255, 255, 0.4));
}
.kg-install-prompt:focus-visible {
  outline: 2px solid var(--blue, var(--primary, #4d96ff));
  outline-offset: 2px;
}
.kg-install-guide {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(45, 45, 45, 0.45);
}
.kg-install-guide[hidden] { display: none !important; }
.kg-install-guide-panel {
  width: min(100%, 360px);
  max-height: min(88vh, 520px);
  overflow: auto;
  background: var(--panel, #fff);
  border-radius: var(--radius, 20px);
  padding: 20px 18px;
  box-shadow: var(--shadow, 0 4px 20px rgba(0, 0, 0, 0.1));
  border: 2px solid rgba(255, 107, 107, 0.2);
}
.kg-install-guide-title {
  font-family: 'Baloo 2', cursive;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary, #ff6b6b);
  margin: 0 0 12px;
  text-align: center;
}
.kg-install-guide-steps {
  margin: 0 0 16px 1.1rem;
  padding: 0;
  font-family: 'Baloo 2', cursive;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text, #222);
}
.kg-install-guide-steps li { margin-bottom: 10px; }
.kg-install-guide-steps li:last-child { margin-bottom: 0; }
.kg-ios-share-icon {
  display: inline-block;
  vertical-align: -0.22em;
  width: 1.15em;
  height: 1.15em;
  margin: 0 0.12em;
  color: var(--blue, var(--primary, #4d96ff));
}
.kg-install-guide-dismiss {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--primary, #4d96ff);
  color: #fff;
  font-family: 'Baloo 2', cursive;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}
.kg-install-guide-dismiss:active { transform: scale(0.98); }

/* ---------- Site footer: sibling games + hub + Built-by / coffee ---------- */
.kg-site-footer {
  width: 100%;
  flex-shrink: 0;
}
/* Installed PWA: home footer stays out of the kid start screen even if JS remounts. */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .kg-site-footer--home { display: none !important; }
}
/* Desktop: footer matches English Buddy start column (760px, 20px padding),
   on the home screen and in parent mode. Play/stats columns stay 420px. */
@media (min-width: 700px) {
  .kg-site-footer {
    box-sizing: border-box;
    width: min(720px, calc(100vw - 40px));
    max-width: min(720px, calc(100vw - 40px));
    /* Center even when the footer is wider than the 420px column.
       Auto side margins would skip centering on overflow and left-align it. */
    align-self: center;
    margin-inline: 0;
  }
}
.kg-footer-nav {
  width: 100%;
  margin-top: 16px;
  padding: 20px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.kg-footer-nav-label {
  margin: 0;
  font-family: 'Baloo 2', cursive;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted, #888);
  letter-spacing: 0.02em;
}
.kg-footer-nav-label a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.kg-footer-nav-label a:hover { color: var(--text, #222); }
.kg-footer-games {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.kg-footer-game {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  color: var(--text, #222);
  text-decoration: none;
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.kg-footer-game:hover {
  border-color: var(--primary, #4d96ff);
  transform: translateY(-1px);
}
.kg-footer-game:active { transform: translateY(1px); }
.kg-footer-game-emoji { font-size: 1.25rem; line-height: 1; }
.kg-footer-game-icon {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  flex-shrink: 0;
}
.kg-footer-hub {
  font-family: 'Baloo 2', cursive;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted, #888);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.kg-footer-hub:hover { color: var(--text, #222); }

/* ---------- Credits (Built by + coffee), part of the site footer ---------- */
.kg-credits {
  text-align: center;
  margin-top: 28px;
  padding: 20px 0 8px;
  color: #666;
  font-size: 0.9em;
  border-top: 2px dashed #e8e8e8;
}
.kg-credits p { margin: 0 0 8px; line-height: 1.45; }
.kg-credits a {
  color: #666;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.kg-credits a:hover { color: #333; }
.kg-credits .buy-me-coffee {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  background: #ffdd44;
  color: #333 !important;
  padding: 10px 18px;
  border-radius: 14px;
  border: 3px solid #d4a800 !important;
  font-weight: 800;
  font-size: 0.9em;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
  box-shadow: 0 4px 0 #c9a000, inset 0 2px 0 rgba(255, 255, 255, 0.45);
  text-decoration: none !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.kg-credits .buy-me-coffee:hover {
  background: #ffe566;
  border-color: #d4a800 !important;
  text-decoration: none;
}
.kg-credits .buy-me-coffee:active {
  transform: translateY(4px);
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.kg-credits .buy-me-coffee svg { flex-shrink: 0; }
@media (max-width: 768px) {
  .kg-credits .buy-me-coffee { padding: 8px 12px; font-size: 0.85em; gap: 6px; }
  .kg-credits .buy-me-coffee svg { width: 16px; height: 16px; }
}

/* ---------- Parent mode: switch player (2+ players) ---------- */
.kg-parent-switch {
  width: 100%;
  margin: -4px 0 16px;
}
.kg-parent-switch[hidden] { display: none; }
.kg-parent-switch-label {
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted, #888);
  margin-bottom: 8px;
}
.kg-parent-switch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kg-parent-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid #e6ddd0;
  background: white;
  color: var(--text, #222);
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.kg-parent-switch-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kg-parent-switch-btn.is-current {
  border-color: var(--purple, #c77dff);
  background: rgba(199, 125, 255, 0.14);
  color: var(--purple, #c77dff);
}
.kg-parent-switch-btn:active { transform: scale(0.97); }

/* ---------- Parent settings: players (reset / delete) ---------- */
.kg-parent-tools {
  width: 100%;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px dashed #e0d6c8;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.kg-parent-tools-heading {
  font-family: 'Baloo 2', cursive;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text, #222);
  margin: 0 0 14px;
}
.kg-player-manage {
  width: 100%;
  padding: 14px 14px 12px;
  margin: 0 0 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1.5px solid #eee4d6;
  box-sizing: border-box;
}
.kg-player-manage-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #888);
  margin-bottom: 4px;
}
.kg-player-manage-hint,
.kg-player-manage-empty {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted, #888);
  line-height: 1.35;
}
.kg-player-manage-empty { margin-bottom: 0; }
.kg-player-manage-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kg-player-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid #eee4d6;
}
.kg-player-row:first-child { border-top: none; padding-top: 4px; }
.kg-player-row:last-child { padding-bottom: 2px; }
.kg-player-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Baloo 2', cursive;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #222);
}
.kg-player-row-name { min-width: 0; }
.kg-player-current {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple, #c77dff);
}
.kg-player-row-actions {
  display: flex;
  gap: 8px;
}
.kg-player-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  border-radius: 12px;
  font-family: 'Baloo 2', cursive;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.2;
}
.kg-player-btn-reset {
  background: white;
  color: var(--text, #222);
  border: 2px solid #e6ddd0;
}
.kg-player-btn-delete {
  background: #ffe8e8;
  color: #c0392b;
  border: 2px solid #ffc9c9;
}
.kg-player-btn:active { transform: scale(0.97); }

.kg-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.42);
}
.kg-confirm-overlay[hidden] { display: none; }
.kg-confirm-card {
  width: 100%;
  max-width: 360px;
  padding: 22px 20px 16px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}
.kg-confirm-msg {
  margin: 0 0 18px;
  font-family: 'Baloo 2', cursive;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text, #222);
}
.kg-confirm-actions {
  display: flex;
  gap: 8px;
}
.kg-confirm-cancel,
.kg-confirm-ok {
  flex: 1;
  padding: 12px 10px;
  border-radius: 14px;
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}
.kg-confirm-cancel {
  background: #f4eee6;
  color: var(--text, #222);
  border: 2px solid #e6ddd0;
}
.kg-confirm-ok {
  background: #ffe8e8;
  color: #c0392b;
  border: 2px solid #ffc9c9;
}
.kg-confirm-ok--danger {
  background: #e85d4c;
  color: white;
  border-color: #c0392b;
}
.kg-confirm-cancel:active,
.kg-confirm-ok:active { transform: scale(0.97); }
