/* Dynamic game view — glass shell matching Kern orbital theme */

.game-view {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 5.5rem 1.25rem 6rem;
  --glass-tint: var(--page-accent, #EAE3D9);
  --glass-fill: color-mix(in srgb, var(--glass-tint) 48%, transparent);
  --glass-fill-strong: color-mix(in srgb, var(--glass-tint) 56%, transparent);
  --glass-rim: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.2));
}
.game-view[data-mood="creativity"] { --page-accent: #F5E3D8; --page-accent-deep: #C57E5C; }
.game-view[data-mood="energy"] { --page-accent: #F7EBC2; --page-accent-deep: #ebc431; }
.game-view[data-mood="focus"] { --page-accent: #D4E2E6; --page-accent-deep: #6A8A92; }
.game-view[data-mood="relax"] { --page-accent: #E2DCED; --page-accent-deep: #8F7FA8; }
.game-view[data-mood="sleep"] { --page-accent: #ADC9E3; --page-accent-deep: #617D94; }
.game-view[data-mood="favourites"] { --page-accent: #EED8D8; --page-accent-deep: #FF716C; }
.game-view[data-mood="recommended"] { --page-accent: #c4e8e0; --page-accent-deep: #629388; }

.game-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--sage-deep, #4A6B44);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 9999px;
  padding: 0.55rem 1.15rem;
  box-shadow: 0 8px 24px rgba(44, 42, 36, 0.08);
  margin-bottom: 1.5rem;
  transition: background 0.2s, transform 0.2s;
}
.game-back:hover {
  background: rgba(255, 255, 255, 0.75);
  transform: translateX(-2px);
}

.game-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(28px, 4.5vw, 42px);
  font-weight: 400;
  color: var(--text-dark, #2C2A24);
  line-height: 1.2;
  margin: 0;
  text-align: center;
  pointer-events: none;
}
.game-meta {
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  color: var(--text-mid, #8C8880);
  margin: 0;
}

.game-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  box-shadow:
    0 16px 48px rgba(44, 42, 36, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  padding: 1.25rem 1.25rem 1.5rem;
  margin-bottom: 0;
}

.game-shell-top {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex: 0 0 auto;
  min-height: 2.75rem;
  margin-bottom: 1rem;
  padding: 0.15rem 0 0.85rem;
  border-bottom: 1px solid rgba(208, 221, 212, 0.65);
}
.game-shell-top .game-title {
  position: absolute;
  left: 50%;
  top: 0.15rem;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(70%, calc(100% - 13rem));
  pointer-events: auto;
}
.game-best-score {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
  margin-right: auto;
  font-family: 'Jost', sans-serif;
  position: relative;
  z-index: 1;
}
.game-best-score-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-mid, #8C8880);
  white-space: nowrap;
}
.game-best-score[hidden] {
  display: none !important;
}

.game-timer-widget {
  display: none !important;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  position: relative;
  z-index: 1;
  margin-left: auto;
}
.game-action-btn {
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 9999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  border: 1px solid rgba(208, 221, 212, 0.9);
  background: rgba(255, 255, 255, 0.55);
  color: var(--text-dark, #2C2A24);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.game-action-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--sage-mid, #8AA882);
}
.game-action-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.game-action-btn.is-primary {
  background: var(--sage-deep, #4A6B44);
  border-color: var(--sage-deep, #4A6B44);
  color: #fff;
}
.game-action-btn.is-primary:hover:not(:disabled) {
  background: var(--accent, #3d5c38);
  border-color: var(--accent, #3d5c38);
  color: #fff;
}
.game-action-btn.is-active {
  background: rgba(228, 237, 225, 0.9);
  border-color: var(--sage-mid, #8AA882);
  color: var(--sage-deep, #4A6B44);
}

.game-host {
  min-height: 320px;
  width: 100%;
  flex: 1 1 auto;
  box-sizing: border-box;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.28);
  padding: 0.75rem;
  overflow: auto;
}
.game-host.kern-game-mounted {
  background: transparent;
  padding: 0;
}

.game-above {
  margin: 0 0 0.95rem;
}
.game-edu-trigger-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 34px;
}
.game-brief {
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-mid, #8C8880);
  text-align: center;
  margin: 0.55rem 0 0;
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.game-brief-kicker {
  display: block;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-mid, #5C574E);
}
.game-brief-body {
  display: block;
}
.game-brief[hidden] {
  display: none !important;
}
.game-edu-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(208, 221, 212, 0.85);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-mid, #5C574E);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.game-edu-toggle svg {
  width: 18px;
  height: 18px;
}
.game-edu-toggle:hover {
  background: #fff;
  border-color: rgba(196, 208, 200, 0.95);
}
.game-edu-toggle[aria-expanded="true"] {
  background: #fff;
}

.game-edu {
  display: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
}
.game-edu.is-open {
  display: block;
  margin: 1.1rem 0 0;
  padding: 1.15rem 1.25rem 1.2rem;
  border: 1px solid rgba(44, 42, 36, 0.14);
  border-radius: 16px;
  background: transparent;
}
.game-edu[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.game-edu-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 400;
  font-style: normal;
  color: var(--text-dark, #2C2A24);
  margin: 0 0 1.15rem;
  line-height: 1.2;
}
.game-edu-body-wrap {
  position: relative;
  z-index: 1;
}
.game-edu-body {
  font-family: 'Jost', sans-serif;
  font-size: clamp(15px, 1.75vw, 17px);
  font-weight: 300;
  line-height: 1.6;
  color: var(--text-dark, #2C2A24);
  margin: 0 0 1.15rem;
}
.game-edu-subhead {
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mid, #5C574E);
  margin: 0 0 0.45rem;
}
.game-edu-how-wrap[hidden] {
  display: none !important;
}
.game-edu-source {
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  color: var(--text-light, #9a968c);
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(208, 221, 212, 0.7);
}

.game-error,
.game-loading {
  font-family: 'Jost', sans-serif;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-mid, #8C8880);
}
.game-error {
  color: #8b4545;
}

html.kern-fs-fallback,
html.kern-fs-fallback body {
  overflow: hidden !important;
  height: 100%;
  height: 100dvh;
}
html.kern-fs-fallback .kern-topnav,
html.kern-fs-fallback .kern-footer,
html.kern-fs-fallback .kern-global-player,
html.kern-fs-fallback #kern-player-fab,
html.kern-fs-fallback .ambient-background,
html.kern-fs-fallback .game-back,
html.kern-fs-fallback .game-above {
  display: none !important;
}
html.kern-fs-fallback .game-view {
  max-width: none;
  padding: 0;
  height: 100dvh;
}

/* Shared difficulty picker — Pattern Flux, People Counter, Word Memory */
.pf-level-label,
.hc-level-label,
.wm-level-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light, #8C8880);
  margin-bottom: 0.65rem;
  text-align: center;
}

.pf-levels,
.hc-levels,
.wm-levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.pf-level,
.hc-level,
.wm-level {
  font-family: 'Jost', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
  width: 100%;
  min-height: 4.75rem;
  padding: 0.85rem 0.75rem;
  border-radius: 14px;
  border: 1.5px solid var(--cream-deep, #DDD5C5);
  background: var(--cream, #FAFAF7);
  color: var(--text-dark, #2C2A24);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.pf-level:hover,
.hc-level:hover,
.wm-level:hover {
  border-color: var(--sage-mid, #8AA882);
  transform: translateY(-1px);
}

.pf-level.is-active,
.hc-level.is-active,
.wm-level.is-active {
  border-color: var(--sage-deep, #4A6B44);
  background: var(--sage-light, #E4EDE1);
}

.pf-level-name,
.hc-level-name,
.wm-level-name {
  font-family: 'DM Serif Display', serif;
  font-size: 17px;
  line-height: 1.2;
}

.pf-level-meta,
.hc-level-time,
.wm-level-meta {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--sage-deep, #4A6B44);
}

@media (max-width: 520px) {
  .pf-levels,
  .hc-levels,
  .wm-levels {
    grid-template-columns: 1fr;
    max-width: 280px;
  }
  .pf-times {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 280px;
  }
}

.pf-time-label {
  margin-top: 1rem;
}

.pf-times {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.pf-time {
  min-height: 3.25rem;
  align-items: center;
}

.game-shell:fullscreen,
.game-shell:-webkit-full-screen,
.game-shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 1rem 1.15rem 1.25rem;
  overflow: hidden;
  border-radius: 0;
  box-sizing: border-box;
  background: var(--white, #fff);
}
.game-shell:fullscreen .game-shell-top,
.game-shell:-webkit-full-screen .game-shell-top,
.game-shell.is-fullscreen .game-shell-top {
  flex: 0 0 auto;
  margin-bottom: 0.75rem;
}
.game-shell:fullscreen .game-host,
.game-shell:-webkit-full-screen .game-host,
.game-shell.is-fullscreen .game-host {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.game-shell:fullscreen .game-host > *,
.game-shell:-webkit-full-screen .game-host > *,
.game-shell.is-fullscreen .game-host > * {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.game-shell:fullscreen .kern-game-root,
.game-shell:-webkit-full-screen .kern-game-root,
.game-shell.is-fullscreen .kern-game-root {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}
.game-shell:fullscreen canvas,
.game-shell:-webkit-full-screen canvas,
.game-shell.is-fullscreen canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.game-shell:fullscreen .pf-grid,
.game-shell:-webkit-full-screen .pf-grid,
.game-shell.is-fullscreen .pf-grid {
  --pf-gap: 0.4rem;
  width: min(100%, calc(var(--pf-cols) * min(4.8rem, 16vmin) + (var(--pf-cols) - 1) * var(--pf-gap)));
  max-height: min(100%, 78vh);
}

.game-view.is-quiz .game-best-score,
.game-view.is-quiz .game-edu-trigger-row,
.game-view.is-quiz .game-edu,
.game-view.is-quiz .game-brief {
  display: none !important;
}
.quiz-frame-host {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 420px;
  border-radius: 18px;
  overflow: hidden;
  background: color-mix(in srgb, var(--page-accent, #c4e8e0) 28%, white);
}
.quiz-frame-host iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 420px;
  border: 0;
  background: transparent;
}
.quiz-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  font-family: 'Jost', sans-serif;
  font-size: 15px;
  color: var(--text-mid, #5C574E);
}
.quiz-empty[hidden],
.quiz-frame-host iframe[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .game-view { padding: 5rem 0.85rem 5.5rem; }
  .game-shell-top {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0;
  }
  .game-shell-top .game-title {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    width: auto;
    max-width: none;
    order: -1;
    margin-bottom: 0.15rem;
  }
  .game-actions { justify-content: stretch; }
  .game-action-btn { flex: 1; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .game-edu-toggle { transition: none; }
}


/* Redesign rollout: navbar home icon replaces the in-page back link (test-game design) */
body.kern-game-page .game-back {
  display: none !important;
}
