/* Kids PC Playground — main styles */

:root {
  --font: 'Fredoka', system-ui, sans-serif;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --touch-min: 48px;
  --touch-big: 64px;
  --bg: linear-gradient(160deg, #667eea 0%, #764ba2 100%);
  --surface: #ffffff;
  --text: #2d3436;
  --text-muted: #636e72;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --success: #00b894;
  --danger: #ff7675;
}

[data-theme="lincoln"] {
  --bg: linear-gradient(160deg, #74b9ff 0%, #0984e3 100%);
  --accent: #0984e3;
  --accent-hover: #0770c9;
}

[data-theme="toby"] {
  --bg: linear-gradient(160deg, #55efc4 0%, #00b894 100%);
  --accent: #00b894;
  --accent-hover: #00a381;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  padding-top: max(1rem, env(safe-area-inset-top));
}

.screen.active {
  display: flex;
}

/* Profile picker */
.welcome-header {
  text-align: center;
  color: #fff;
  margin-bottom: 2rem;
}

.welcome-header h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin: 0 0 0.5rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.subtitle {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  margin: 0;
  opacity: 0.95;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.25rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 160px;
  padding: 1.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font);
}

.profile-card:active {
  transform: scale(0.97);
}

.profile-lincoln { border-bottom: 5px solid #0984e3; }
.profile-toby { border-bottom: 5px solid #00b894; }

.profile-avatar {
  font-size: 3.5rem;
  line-height: 1;
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.profile-age {
  font-size: 1rem;
  color: var(--text-muted);
}

.parent-tip {
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  margin-top: auto;
  padding-top: 2rem;
}

/* App header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: #fff;
}

.app-header h2 {
  margin: 0;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  flex: 1;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.btn-icon:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.4);
}

/* Hub grid */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 1rem;
  flex: 1;
  align-content: start;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

[data-difficulty="easy"] .hub-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  gap: 1.25rem;
}

.hub-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touch-big);
  padding: 1.25rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s ease;
}

[data-difficulty="easy"] .hub-tile {
  min-height: 120px;
  padding: 1.5rem 1rem;
}

.hub-tile:active {
  transform: scale(0.96);
}

.hub-tile-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

[data-difficulty="easy"] .hub-tile-emoji {
  font-size: 3rem;
}

.hub-tile-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

[data-difficulty="easy"] .hub-tile-label {
  font-size: 1.2rem;
}

.btn-secondary {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.75rem 1.5rem;
  min-height: var(--touch-min);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Activity mount */
.activity-mount {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
}

.activity-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  min-height: 0;
  overflow: auto;
}

.activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  align-items: center;
  justify-content: center;
}

.activity-status {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0.75rem;
  color: var(--text);
}

.btn-tool {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  border: 2px solid #dfe6e9;
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
}

.btn-tool.active {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.1);
}

.btn-tool:active {
  transform: scale(0.95);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:active {
  background: var(--accent-hover);
  transform: scale(0.98);
}

/* Click Party */
.click-area {
  flex: 1;
  position: relative;
  min-height: 300px;
  background: linear-gradient(180deg, #dfe6e9 0%, #b2bec3 100%);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
}

.click-target {
  position: absolute;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: float 2s ease-in-out infinite;
  touch-action: manipulation;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.click-target:active {
  transform: scale(0.85) !important;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.85);
  z-index: 2;
}

.start-text {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.combo-display {
  color: var(--accent);
}

.pop-particle {
  position: absolute;
  font-size: 1.25rem;
  pointer-events: none;
  animation: particleBurst 0.5s ease-out forwards;
  z-index: 5;
}

@keyframes particleBurst {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

.score-bar {
  display: flex;
  justify-content: space-around;
  padding: 0.75rem;
  font-weight: 600;
  font-size: 1.1rem;
}

/* Memory Match */
.memory-grid {
  display: grid;
  gap: 0.75rem;
  justify-content: center;
  margin: auto;
  padding: 0.5rem;
  perspective: 800px;
}

.memory-card {
  aspect-ratio: 1;
  min-width: 70px;
  min-height: 70px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  position: relative;
  transform-style: preserve-3d;
}

.memory-card .card-back,
.memory-card .card-front {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 2rem;
  backface-visibility: hidden;
  transition: transform 0.35s ease;
}

.memory-card .card-back {
  background: var(--accent);
  color: #fff;
  transform: rotateY(0deg);
}

.memory-card .card-front {
  background: #fff;
  border: 3px solid var(--accent);
  transform: rotateY(180deg);
}

.memory-card.flipped .card-back {
  transform: rotateY(180deg);
}

.memory-card.flipped .card-front {
  transform: rotateY(0deg);
}

[data-difficulty="easy"] .memory-card {
  min-width: 72px;
  min-height: 72px;
}

[data-difficulty="easy"] .memory-card .card-back,
[data-difficulty="easy"] .memory-card .card-front {
  font-size: 2rem;
}

.memory-card.matched {
  opacity: 0.65;
  cursor: default;
}

.memory-card.matched .card-front {
  border-color: var(--success);
  background: rgba(0, 184, 148, 0.1);
}

.memory-card:not(.flipped):not(.matched):active {
  transform: scale(0.95);
}

.moves-count {
  font-size: 0.95rem !important;
  padding-top: 0 !important;
  color: var(--text-muted);
}

/* Learn Zone */
.learn-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
}

.learn-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.letter-grid,
.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.5rem;
  width: 100%;
  max-width: 500px;
}

.letter-btn,
.number-btn {
  min-height: var(--touch-min);
  border: 2px solid #dfe6e9;
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

.letter-btn:active,
.number-btn:active {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--accent);
}

.big-display {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.big-display.display-pop {
  transform: scale(1.15);
}

.status-success {
  color: var(--success) !important;
}

.counting-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  font-size: 2.5rem;
  min-height: 80px;
}

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.math-problem {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
}

.word-slots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.word-slot {
  width: 48px;
  height: 56px;
  border: 3px dashed var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.word-slot.filled {
  border-style: solid;
  background: rgba(108, 99, 255, 0.1);
}

.letter-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Drag & Drop */
.drag-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 280px;
}

.drop-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
  background: #f1f2f6;
  border-radius: var(--radius-sm);
}

.drop-slot {
  width: 100px;
  height: 110px;
  border: 3px dashed #b2bec3;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  background: #fff;
}

[data-difficulty="easy"] .drop-slot {
  width: 110px;
  height: 120px;
}

.drop-slot-label {
  font-size: 2rem;
  line-height: 1;
}

.drop-slot-hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.drop-slot.drag-over,
.drop-bin-area.drag-over,
.drop-bin.drag-over .drop-bin-area {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.12);
  transform: scale(1.05);
}

.drop-slot.filled,
.drop-success {
  border-style: solid;
  border-color: var(--success);
  background: rgba(0, 184, 148, 0.08);
}

.drag-tray {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 2px dashed #dfe6e9;
  min-height: 100px;
}

.drag-items {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
}

.drag-chip {
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  cursor: grab;
  transition: transform 0.15s, opacity 0.15s;
}

[data-difficulty="easy"] .drag-chip {
  width: 100px;
  height: 100px;
  font-size: 3rem;
}

.drag-chip-animal {
  background: #fff;
  border: 3px solid #eee;
}

.drag-chip-emoji {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.drag-chip.dragging {
  cursor: grabbing;
}

.drag-chip.drag-source {
  opacity: 0.25;
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  transform: scale(1.08);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.drop-bins {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.drop-bin {
  background: #f8f9fa;
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 2px solid #eee;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.drop-bin.drop-success {
  border-color: var(--success);
  background: rgba(0, 184, 148, 0.06);
}

.drop-bin-icon {
  font-size: 2rem;
  display: block;
}

.drop-bin-label {
  font-weight: 700;
  font-size: 1rem;
  display: block;
  margin-bottom: 0.5rem;
}

.drop-bin-area {
  min-height: 90px;
  border: 3px dashed #ccc;
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-content: flex-start;
  justify-content: center;
  padding: 0.5rem;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.bin-item {
  font-size: 2rem;
  animation: popIn 0.3s ease;
}

.play-again-btn {
  display: block;
  margin: 0.5rem auto 1rem;
}

/* Keyboard Fun */
.keyboard-modes {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.keyboard-prompt {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 1rem 0;
}

.target-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  font-size: 3rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  margin: 0.5rem auto;
  transition: transform 0.2s, background 0.2s;
}

.target-letter.target-success {
  transform: scale(1.15);
  background: var(--success);
}

.typed-display {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  min-height: 3rem;
  color: var(--accent);
}

.on-screen-keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 1rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.key-btn {
  min-width: 36px;
  min-height: 44px;
  padding: 0.5rem;
  border: 2px solid #dfe6e9;
  border-radius: 8px;
  background: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.key-btn.space {
  min-width: 120px;
}

.key-btn.highlight {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.key-btn:active {
  transform: scale(0.95);
}

.key-btn-big {
  min-width: 44px;
  min-height: 52px;
  font-size: 1.15rem;
}

/* Draw Studio */
.draw-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.color-palette {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.color-swatch.active {
  border-color: var(--text);
  transform: scale(1.1);
}

.draw-canvas {
  flex: 1;
  width: 100%;
  min-height: 250px;
  background: #fff;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

.sticker-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.sticker-btn {
  font-size: 1.75rem;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}

.sticker-btn.active {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.1);
}

/* Win overlay */
.win-banner {
  text-align: center;
  padding: 1.5rem;
  animation: popIn 0.4s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.win-banner h3 {
  font-size: 1.75rem;
  margin: 0 0 1rem;
  color: var(--success);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .click-target {
    animation: none;
  }
}

/* Desktop */
@media (min-width: 768px) {
  .screen {
    padding: 1.5rem 2rem;
  }

  .hub-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .profile-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  }

  .hub-tile:hover {
    transform: translateY(-3px);
  }
}
