/**
 * まなびぽっぷ！ 共通スタイル
 * 軽量カートゥーンマップ、音、フィードバック、子ども向けUI
 */

/* Root & Base Settings */
:root {
  --primary-glow: rgba(99, 102, 241, 0.4);
  --amber-glow: rgba(245, 158, 11, 0.4);
  --success-glow: rgba(16, 185, 129, 0.4);
  --error-glow: rgba(239, 68, 68, 0.4);
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8bd8ff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

*, *::before, *::after {
  box-sizing: border-box;
}

button, input, select, textarea, p, h1, h2, h3, h4, strong, span {
  min-width: 0;
}

button, p, h1, h2, h3, h4, strong, span {
  overflow-wrap: anywhere;
  word-break: normal;
}

button {
  line-height: 1.45;
}

#canvas-container {
  position: absolute;
  inset: 0;
  touch-action: none;
  z-index: 1;
}

/* 制作イラストを使う冒険マップ。常時WebGL処理を行わない。 */
.cartoon-map-container {
  overflow: hidden;
  background: #4b9ec9;
}

.cartoon-map-world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #6dc6e8 url('../assets/maps/manabi-adventure-map.webp') center center / cover no-repeat;
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}

.cartoon-map-world[data-theme],.shop-map-preview[data-theme]{background-size:100% auto,cover;background-position:center;background-repeat:no-repeat}
/* Keep purchased IDs stable while giving the illustrated map matching decorations. */
.cartoon-map-world[data-theme="skin_nebula_aurora"],.shop-map-preview[data-theme="skin_nebula_aurora"] {
  background-position:center bottom,center;
  background-image:url('../assets/maps/garden-decoration.svg'),url('../assets/maps/manabi-adventure-map.webp');
}
.cartoon-map-world[data-theme="skin_cyber_neon"],.shop-map-preview[data-theme="skin_cyber_neon"] {
  background-position:center top,center;
  background-image:url('../assets/maps/festival-decoration.svg'),url('../assets/maps/manabi-adventure-map.webp');
}
.cartoon-map-world[data-theme="skin_nebula_aurora"] .map-art-shade {background:linear-gradient(180deg,#ffe5ec18,transparent 55%,#97b95820)}
.cartoon-map-world[data-theme="skin_cyber_neon"] .map-art-shade {background:linear-gradient(180deg,#fff1c52b,transparent 55%,#ffc68a20)}
.shop-map-preview{width:104px;height:72px;flex-shrink:0;border:2px solid #fff2cf;border-radius:12px;background:#6dc6e8 center/cover no-repeat;background-image:url('../assets/maps/manabi-adventure-map.webp')}
@media(max-width:480px){.shop-map-preview{width:72px;height:64px}}

.map-art-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(17,48,85,.12), transparent 28%, transparent 72%, rgba(12,35,45,.28)),
    radial-gradient(circle at 50% 45%, transparent 25%, rgba(16,43,67,.18) 115%);
}
.map-sparkles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.map-sparkles span {
  position: absolute; width: .55rem; height: .55rem; border-radius: 50%;
  background: #fff6a5; box-shadow: 0 0 0 3px rgba(255,246,165,.22), 0 0 18px 5px rgba(255,239,119,.55);
  animation: map-sparkle-pulse 2.8s ease-in-out infinite alternate;
}
.map-sparkles span:nth-child(1) { left: 12%; top: 28%; animation-delay: -.8s; }
.map-sparkles span:nth-child(2) { left: 29%; top: 62%; animation-delay: -1.6s; }
.map-sparkles span:nth-child(3) { left: 48%; top: 36%; animation-delay: -.3s; }
.map-sparkles span:nth-child(4) { left: 67%; top: 69%; animation-delay: -2.1s; }
.map-sparkles span:nth-child(5) { left: 83%; top: 31%; animation-delay: -1.2s; }
.map-sparkles span:nth-child(6) { left: 91%; top: 77%; animation-delay: -2.5s; }
.map-caption {
  position: absolute; left: 50%; top: 8rem; z-index: 4; transform: translateX(-50%);
  max-width: min(88vw, 34rem); padding: .55rem 1.15rem; border: 2px solid rgba(255,255,255,.92);
  border-radius: 999px; color: #19365b; background: rgba(255,255,255,.94);
  box-shadow: 0 5px 0 rgba(39,92,128,.28), 0 10px 25px rgba(28,67,97,.2);
  font-size: clamp(.78rem, 2vw, 1rem); font-weight: 1000; text-align: center;
}
.map-node-layer {
  position: absolute; z-index: 5;
  left: clamp(10.5rem, 16vw, 13rem); right: clamp(25rem, 31vw, 27rem);
  top: 10.75rem; bottom: 1.25rem;
  display: flex; flex-direction: column; gap: .7rem; overflow: auto; padding: .3rem .55rem 1rem;
  overscroll-behavior: contain; touch-action: pan-x pan-y;
}
.map-unit-route {
  --route-color: #4f85d7; --route-dark: #28568e; --route-soft: #e7f2ff;
  position: relative; flex: 0 0 auto; display: grid; grid-template-columns: minmax(9.5rem, 12.5rem) minmax(0, 1fr);
  min-height: 4.65rem; overflow: hidden; border: 2px solid rgba(255,255,255,.9); border-radius: 1.35rem;
  color: #142b48; background: linear-gradient(100deg, rgba(255,255,255,.96), rgba(245,250,255,.84));
  box-shadow: 0 5px 0 #355a82, 0 12px 24px rgba(14,42,65,.25);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--route-dark) 72%, #28384d), 0 12px 24px rgba(14,42,65,.25);
}
.map-unit-route[data-subject="国語"] { --route-color:#f06b73; --route-dark:#a83d50; --route-soft:#fff0f1; }
.map-unit-route[data-subject="算数"] { --route-color:#4f8df2; --route-dark:#2b59a8; --route-soft:#edf4ff; }
.map-unit-route[data-subject="理科"] { --route-color:#39b77b; --route-dark:#24764f; --route-soft:#edfff6; }
.map-unit-route[data-subject="社会"] { --route-color:#e9a93b; --route-dark:#986618; --route-soft:#fff8e8; }
.map-unit-route[data-subject="生活"] { --route-color:#68b84c; --route-dark:#397d2a; --route-soft:#f2ffe9; }
.map-unit-route[data-subject="外国語・英語"],
.map-unit-route[data-subject="英語"] { --route-color:#9a69e8; --route-dark:#633ca5; --route-soft:#f7efff; }
.map-unit-select {
  display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); align-items: center; gap: .55rem;
  min-height: 100%; padding: .55rem .65rem; border: 0; border-right: 2px solid rgba(82,119,157,.35);
  border-right-color: color-mix(in srgb, var(--route-color) 42%, white);
  color: #173252; background: linear-gradient(135deg, var(--route-soft), rgba(255,255,255,.94));
  cursor: pointer; text-align: left;
}
.map-unit-select:hover, .map-unit-select:focus-visible { filter: saturate(1.16) brightness(1.02); outline: 3px solid var(--route-color); outline-offset: -3px; }
.map-node-bubble {
  display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border: 2px solid #fff; border-radius: .9rem;
  color: #fff; background: var(--route-color); box-shadow: 0 4px 0 var(--route-dark); font-size: 1.35rem;
}
.map-node-label { display: block; min-width: 0; }
.map-node-label small { display: block; color: var(--route-dark); font-size: .58rem; font-weight: 1000; line-height: 1.3; }
.map-node-label strong { display: -webkit-box; overflow: hidden; color: #173252; font-size: .7rem; font-weight: 1000; line-height: 1.35; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.map-stage-track {
  position: relative; display: flex; align-items: center; gap: .55rem; overflow-x: auto; overflow-y: hidden;
  min-width: 0; padding: .75rem 2.7rem .75rem .85rem; scroll-snap-type: x proximity; overscroll-behavior-x: contain;
}
.map-stage-track::before {
  content: ''; position: absolute; left: 1.1rem; right: 2.8rem; top: 50%; height: .3rem; transform: translateY(-50%);
  border-radius: 999px; background: repeating-linear-gradient(90deg, var(--route-color) 0 1.1rem, transparent 1.1rem 1.65rem); opacity: .48;
}
.map-stage-stop {
  position: relative; z-index: 1; flex: 0 0 2.65rem; display: grid; place-items: center; min-width: 2.65rem; width: 2.65rem; min-height: 2.65rem;
  padding: 0; border: 2px solid #fff; border-radius: 50%; color: #fff; background: var(--route-color);
  box-shadow: 0 4px 0 var(--route-dark), 0 6px 12px rgba(20,48,73,.22); font-size: .72rem; font-weight: 1000;
  scroll-snap-align: center; cursor: pointer; transition: transform .14s ease, filter .14s ease;
}
.map-stage-stop:hover, .map-stage-stop:focus-visible { transform: translateY(-4px) scale(1.08); filter: brightness(1.08); outline: 3px solid rgba(255,255,255,.7); }
.map-stage-stop.is-cleared { color: #17452d; background: #9cf09f; box-shadow: 0 4px 0 #3f8c55, 0 0 0 3px rgba(255,255,255,.3); }
.map-scroll-hint {
  position: absolute; z-index: 3; right: .45rem; bottom: .2rem; padding: .12rem .35rem; border-radius: 999px;
  color: var(--route-dark); background: rgba(255,255,255,.92); font-size: .48rem; font-weight: 1000; pointer-events: none;
}
.map-stage-cleared .map-unit-select { background: linear-gradient(135deg, #d9ffd9, #fff); }
.map-stage-locked { opacity: .88; }
.map-node-celebrate { animation: map-node-pop .65s ease both; }
.map-empty-message { margin: auto; padding: 1rem 1.4rem; border-radius: 1rem; color: #18304e; background: rgba(255,255,255,.92); font-weight: 1000; }
@keyframes map-node-pop { 50% { transform: translateY(-8px) scale(1.025); filter: brightness(1.12); } }
@keyframes map-sparkle-pulse { to { opacity: .28; transform: scale(.6) rotate(45deg); } }
@keyframes map-theme-shimmer { to { opacity: .58; transform: scale(1.025); } }

/* ゲーム先行モードの、読みやすいカラフルなカード。 */
.independent-game-card {
  --card-a: #7657e8; --card-b: #b16cff; --card-ink: #fff;
  position: relative; display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); grid-template-rows: auto auto auto;
  column-gap: .7rem; min-height: 10rem; padding: 1rem; overflow: hidden; border: 3px solid rgba(255,255,255,.88);
  border-radius: 1.35rem; color: var(--card-ink); text-align: left;
  background: linear-gradient(145deg, var(--card-a), var(--card-b));
  box-shadow: 0 7px 0 rgba(31,43,77,.55), 0 12px 22px rgba(12,22,47,.28);
  transition: transform .16s ease, filter .16s ease;
}
.independent-game-card::after { content: ''; position: absolute; right: 0; top: 0; width: 5.5rem; height: 5.5rem; border-radius: 0 0 0 100%; background: rgba(255,255,255,.16); }
.independent-game-card:hover, .independent-game-card:focus-visible { transform: translateY(-4px) rotate(-.6deg); filter: saturate(1.12) brightness(1.04); outline: 4px solid rgba(255,255,255,.42); }
.independent-game-icon { grid-row: 1 / 4; display: grid; place-items: center; align-self: start; width: 3.4rem; height: 3.4rem; border: 3px solid rgba(255,255,255,.72); border-radius: 1rem; background: rgba(255,255,255,.2); font-size: 2rem; }
.independent-game-name { position: relative; z-index: 1; display: block; font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Noto Sans JP", system-ui, sans-serif; font-size: clamp(.9rem, 2vw, 1.05rem); font-weight: 1000; line-height: 1.3; text-shadow: 0 2px 0 rgba(29,25,77,.28); }
.independent-game-description { position: relative; z-index: 1; display: block; margin-top: .28rem; font-size: .72rem; font-weight: 700; line-height: 1.55; color: rgba(255,255,255,.94); }
.independent-game-grades { position: relative; z-index: 1; display: block; align-self: end; margin-top: .45rem; padding: .28rem .5rem; border-radius: .6rem; background: rgba(13,26,56,.22); font-size: .62rem; font-weight: 900; line-height: 1.4; }
.game-card-berry { --card-a:#f04b8c; --card-b:#9b5de5; }
.game-card-orange { --card-a:#ff7b54; --card-b:#ffb347; }
.game-card-green { --card-a:#29a96b; --card-b:#6fd46d; }
.game-card-yellow { --card-a:#f4a62a; --card-b:#f5d04c; --card-ink:#2f3551; }
.game-card-sky { --card-a:#318ee7; --card-b:#67d4f2; }
.game-card-aqua { --card-a:#05a7a0; --card-b:#50d8c7; }
.game-card-violet { --card-a:#6556d9; --card-b:#a07bf2; }
.game-card-lime { --card-a:#52a83f; --card-b:#a3d84f; --card-ink:#183a2d; }
.game-card-gold { --card-a:#f29b25; --card-b:#ffe064; --card-ink:#443510; }
.game-card-mint { --card-a:#1eae82; --card-b:#72dab4; --card-ink:#143f36; }
.game-card-coral { --card-a:#ec6262; --card-b:#ff9671; }
.game-card-amber { --card-a:#b87816; --card-b:#efb840; }
.game-card-pink { --card-a:#e5539b; --card-b:#ff91b8; }
.game-card-rainbow { --card-a:#6759dc; --card-b:#f06ca8; }
.game-card-peach { --card-a:#e87e58; --card-b:#f7ad72; }
.game-card-leaf { --card-a:#389d57; --card-b:#8dcc5d; }
.game-card-royal { --card-a:#6532a8; --card-b:#df7b37; }

/* Glassmorphism Panels */
.glass-panel {
  /* Nearly opaque panels keep labels legible on every selectable backdrop. */
  background: rgba(8, 15, 30, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(226, 232, 240, 0.38);
}

.glass-panel-subtle {
  background: rgba(8, 15, 30, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.28);
}

/* Canvas games must not inherit a bright/complex scene through transparency. */
#game-canvas {
  display: block;
  background: #08111f;
}

.shop-hint-flash {
  animation: shop-hint-flash 1.1s ease-in-out 2;
}

@keyframes shop-hint-flash {
  0%, 100% { filter: none; box-shadow: inset 0 0 0 0 rgba(34,211,238,0); }
  50% { filter: brightness(1.13) saturate(1.18); box-shadow: inset 0 0 28px 8px rgba(34,211,238,.55); }
}

#game-modal .text-slate-400,
#game-modal .text-slate-300 {
  color: #cbd5e1;
}

#game-modal button,
#game-overlay-ui button,
#game-type-modal button,
#learning-mode-modal button,
#user-modal button {
  white-space: normal;
  overflow-wrap: anywhere;
}

#game-overlay-ui > * {
  max-width: calc(100% - 1rem);
  max-height: calc(100% - 1rem);
}

#game-overlay-ui p,
#game-overlay-ui strong,
#game-overlay-ui span {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

@supports (height: 100dvh) {
  .fixed.inset-0 { min-height: 100dvh; }
}

/* Custom Scrollbars */
.custom-scroll::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.custom-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 4px;
}
.custom-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Hide scrollbar completely while maintaining scrollability */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Top grade selector: visible toggle button with a click-only dropdown */
#grade-tabs-container {
  pointer-events: auto;
  top: max(4.25rem, calc(env(safe-area-inset-top) + 3.75rem)) !important;
}

#grade-tabs {
  max-height: min(70vh, 28rem);
  overflow-y: auto;
}

/* ==========================================================================
   Screen Shake & Motion Feedback Animations
   ========================================================================== */

/* 1. Gentle Cartoon Wobble (For Tier 1 Pedagogical Error Feedback) */
@keyframes cartoon-wobble {
  0% { transform: translateX(0) rotate(0deg); }
  15% { transform: translateX(-6px) rotate(-3deg) scale(0.98); }
  30% { transform: translateX(6px) rotate(2.5deg) scale(1.02); }
  45% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(4px) rotate(1.2deg); }
  75% { transform: translateX(-2px) rotate(-0.5deg); }
  100% { transform: translateX(0) rotate(0deg) scale(1.0); }
}

.animate-cartoon-wobble {
  animation: cartoon-wobble 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* 2. Screen Shake Light (Canvas or HUD elements) */
@keyframes screen-shake-light {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -2px); }
  60% { transform: translate(-1px, 2px); }
  80% { transform: translate(1px, -1px); }
}

.animate-screen-shake-light {
  animation: screen-shake-light 0.22s ease-in-out both;
}

/* 3. Screen Shake Medium */
@keyframes screen-shake-medium {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 3px); }
  30% { transform: translate(4px, -4px); }
  45% { transform: translate(-4px, 2px); }
  60% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, 1px); }
  90% { transform: translate(1px, -1px); }
}

.animate-screen-shake-medium {
  animation: screen-shake-medium 0.32s ease-in-out both;
}

/* 4. Screen Shake Heavy (Boss / Big Victory events) */
@keyframes screen-shake-heavy {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-9px, 5px) rotate(-1deg); }
  25% { transform: translate(8px, -7px) rotate(1deg); }
  40% { transform: translate(-7px, 6px); }
  55% { transform: translate(6px, -4px); }
  70% { transform: translate(-4px, 3px); }
  85% { transform: translate(2px, -2px); }
}

.animate-screen-shake-heavy {
  animation: screen-shake-heavy 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ==========================================================================
   Tier 2 Clue Pulsing & Visual Scaffolding Glows
   ========================================================================== */

@keyframes clue-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.8), inset 0 0 10px rgba(245, 158, 11, 0.4);
    border-color: rgba(245, 158, 11, 1);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(245, 158, 11, 0), inset 0 0 18px rgba(245, 158, 11, 0.7);
    border-color: rgba(251, 191, 36, 1);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0), inset 0 0 10px rgba(245, 158, 11, 0.4);
    border-color: rgba(245, 158, 11, 0.8);
    transform: scale(1);
  }
}

.animate-clue-pulse {
  animation: clue-pulse 1.2s ease-in-out infinite;
}

/* Gentle Floating Bounce for Mascot & Badges */
@keyframes bounce-gentle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.animate-bounce-gentle {
  animation: bounce-gentle 2.4s ease-in-out infinite;
}

/* Cosmic Shimmer Glow */
@keyframes cosmic-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.shimmer-gradient {
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #f59e0b, #6366f1);
  background-size: 300% 300%;
  animation: cosmic-shimmer 6s ease infinite;
}

/* Global FX Fullscreen Canvas Overlay */
#global-fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* Mascot Speech Bubble Container */
#guidance-bubble {
  filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.6));
}

/* Mute Button Active States */
#audio-mute-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
#audio-mute-btn:hover {
  transform: scale(1.06);
}
#audio-mute-btn:active {
  transform: scale(0.94);
}

/* Learning entrance: colorful, animated まなびぽっぷ！ wordmark. */
.pses-game-brand-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  margin: -0.25rem auto 0.75rem;
  isolation: isolate;
  overflow: hidden;
}

.pses-game-brand-shell::before {
  content: '';
  position: absolute;
  z-index: -2;
  width: min(82%, 34rem);
  height: 5rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.34), rgba(168, 85, 247, 0.38), rgba(251, 191, 36, 0.34));
  filter: blur(24px);
  animation: pses-brand-aurora 5.5s ease-in-out infinite alternate;
}

.pses-game-brand {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.22em;
  margin: 0;
  padding: 0.2em 0.45em;
  font-family: "Arial Rounded MT Bold", "Noto Sans JP", system-ui, sans-serif;
  font-size: clamp(2.5rem, 9vw, 4.9rem);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: .02em;
  filter: drop-shadow(0 5px 0 rgba(15, 23, 42, 0.8)) drop-shadow(0 12px 24px rgba(56, 189, 248, 0.28));
  animation: pses-brand-float 3.2s ease-in-out infinite;
}

.pses-game-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(105deg, transparent 28%, rgba(255, 255, 255, 0.82) 45%, transparent 61%);
  transform: translateX(-135%) skewX(-18deg);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: pses-brand-shine 3.8s ease-in-out infinite;
}

.pses-game-brand-primary,
.pses-game-brand-secondary {
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.65);
}

.pses-game-brand-primary {
  background-image: linear-gradient(105deg, #22d3ee 0%, #60a5fa 25%, #a78bfa 52%, #f472b6 76%, #fb7185 100%);
}

.pses-game-brand-secondary {
  background-image: linear-gradient(105deg, #fbbf24 0%, #fb7185 45%, #c084fc 100%);
  font-size: 0.62em;
  letter-spacing: -0.025em;
}

.pses-game-orbit {
  position: absolute;
  z-index: -1;
  width: min(72vw, 31rem);
  height: 4.5rem;
  border: 2px solid rgba(125, 211, 252, 0.35);
  border-radius: 50%;
  transform: rotate(-7deg);
  animation: pses-brand-orbit 8s linear infinite;
}

.pses-game-orbit-two {
  width: min(63vw, 27rem);
  height: 6.1rem;
  border-color: rgba(251, 191, 36, 0.24);
  transform: rotate(10deg);
  animation-direction: reverse;
  animation-duration: 10s;
}

.pses-game-star {
  position: absolute;
  color: #fde68a;
  text-shadow: 0 0 12px currentColor;
  animation: pses-brand-twinkle 1.8s ease-in-out infinite alternate;
}

.pses-game-star-one { left: 10%; top: 20%; color: #67e8f9; font-size: 1.15rem; }
.pses-game-star-two { right: 12%; top: 18%; color: #f9a8d4; font-size: 1.45rem; animation-delay: -0.8s; }
.pses-game-star-three { right: 19%; bottom: 17%; color: #fde68a; font-size: 0.65rem; animation-delay: -1.25s; }

@keyframes pses-brand-float {
  0%, 100% { transform: translateY(0) rotate(-0.6deg); }
  50% { transform: translateY(-8px) rotate(0.6deg); }
}

@keyframes pses-brand-shine {
  0%, 55% { transform: translateX(-135%) skewX(-18deg); opacity: 0; }
  65% { opacity: 0.8; }
  88%, 100% { transform: translateX(135%) skewX(-18deg); opacity: 0; }
}

@keyframes pses-brand-aurora {
  from { transform: scale(0.92) translateX(-3%); opacity: 0.68; }
  to { transform: scale(1.08) translateX(3%); opacity: 1; }
}

@keyframes pses-brand-orbit {
  from { transform: rotate(-7deg); }
  to { transform: rotate(353deg); }
}

@keyframes pses-brand-twinkle {
  from { transform: scale(0.65) rotate(-12deg); opacity: 0.45; }
  to { transform: scale(1.2) rotate(12deg); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pses-game-brand,
  .pses-game-brand::after,
  .pses-game-brand-shell::before,
  .pses-game-orbit,
  .pses-game-star {
    animation: none !important;
  }
}

/* Child-Friendly Ergonomics: Touch Target Scaling */
@media (max-width: 768px) {
  button, .subj-btn, .grade-tab-btn {
    min-height: 56px;
    touch-action: manipulation;
  }

  #subject-nav {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: 118px !important;
    transform: none !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: calc(100vw - 16px);
  }

  #subject-nav-heading,
  #subject-nav > div:first-child { display: none; }
  #subject-nav .subj-btn { flex: 0 0 auto; padding: 6px 10px; white-space: nowrap; }
  
  #guidance-bubble {
    right: 12px;
    bottom: 16px;
    max-width: calc(100vw - 24px);
  }

  #grade-tabs-container { top: max(3.75rem, calc(env(safe-area-inset-top) + 3.5rem)) !important; }
  header { top: 6px !important; left: 8px !important; right: 8px !important; gap: 4px; }
  header > div { gap: 4px !important; }
  header button, header .glass-panel { min-height: 44px !important; padding-inline: .5rem !important; }
  #user-profile-btn { max-width: 7.5rem; padding-inline: .55rem !important; }
  #current-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .glass-panel { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .cartoon-map-world { background-position: 54% center; }
  .map-caption { display: none; }
  .map-node-layer { left: 8px; right: 8px; top: 184px; bottom: 10px; gap: .65rem; padding-inline: .25rem; }
  .map-unit-route { grid-template-columns: minmax(7.8rem, 9.3rem) minmax(0, 1fr); min-height: 4.75rem; border-radius: 1.15rem; }
  .map-unit-select { min-height: 4.75rem !important; grid-template-columns: 2.3rem minmax(0, 1fr); gap: .4rem; padding: .45rem; }
  .map-node-bubble { width: 2.25rem; height: 2.25rem; font-size: 1.15rem; }
  .map-node-label strong { font-size: .63rem; }
  .map-node-label small { font-size: .52rem; }
  .map-stage-track { padding-inline: .65rem 2.6rem; gap: .48rem; }
  .map-stage-stop { flex-basis: 2.75rem; min-width: 2.75rem; width: 2.75rem; min-height: 2.75rem !important; }
  .pses-game-brand-shell { min-height: 105px; }
  .pses-game-brand { font-size: clamp(2.15rem, 12vw, 3.2rem); }
  #learning-mode-modal > div { padding: 1rem !important; border-radius: 1.4rem; }
  #learning-mode-choice-panel > button { min-height: 0 !important; padding: 1rem !important; }
  #independent-game-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #independent-game-list > button { min-height: 9.5rem !important; padding: .8rem !important; }
  #game-modal > div { max-height: calc(100dvh - .5rem) !important; overflow-y: auto; border-radius: 1.25rem; }
  #game-stage { flex: 0 0 auto; height: min(60dvh, 420px) !important; min-height: 300px; }
  #game-title { white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
  #game-hint { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.35; }
}

@media (max-width: 380px) {
  #user-profile-btn { width: 44px; overflow: hidden; }
  #user-profile-btn #current-user-name,
  #user-profile-btn span:last-child,
  #streak-counter { display: none; }
  header > div:last-child { flex: 1; justify-content: flex-end; }
  header button, header .glass-panel { min-width: 40px; padding-inline: .4rem !important; }
  #subject-nav { top: 112px !important; }
  .map-node-layer { top: 178px; }
  .map-unit-route { grid-template-columns: 7.2rem minmax(0, 1fr); }
  .map-unit-select { grid-template-columns: 2rem minmax(0, 1fr); padding-inline: .35rem; }
  .map-node-bubble { width: 2rem; height: 2rem; font-size: 1rem; }
  .map-node-label strong { font-size: .58rem; }
  .map-node-label small { font-size: .48rem; }
  #independent-game-list { grid-template-columns: 1fr; }
  #independent-game-list > button { min-height: 7.5rem !important; }
}

@media (prefers-reduced-motion: reduce) {
  .map-stage-stop, .map-node-celebrate, .map-sparkles span, .map-art-shade { animation: none !important; transition: none !important; }
  .shop-hint-flash { animation: none !important; outline: 4px solid rgba(34,211,238,.7); outline-offset: -4px; }
}
