/* Gameplay Layout */
.gameplay-container {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 24px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1200px) {
  .gameplay-container {
    grid-template-columns: 1fr;
  }
  
  .game-sidebar {
    position: relative;
    width: 100%;
  }
  
  .side-panel {
    order: -1;
  }
}

/* Game Sidebar */
.game-sidebar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 20px;
  height: fit-content;
}

.game-sidebar h3 {
  font-family: 'Baloo 2', cursive;
  font-size: 18px;
  margin-bottom: 16px;
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  width: 100%;
}

.game-card:hover {
  border-color: var(--purple);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.game-card.active {
  border-color: var(--purple);
  background: var(--purple-l);
}

.game-card .game-emoji {
  font-size: 36px;
  margin-bottom: 8px;
}

.game-card .game-name {
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  font-size: 14px;
}

.game-card .game-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Mini Leaderboard */
.mini-leaderboard {
  border-top: 2px solid var(--bg);
  padding-top: 16px;
}

.mini-leaderboard h4 {
  font-family: 'Baloo 2', cursive;
  font-size: 14px;
  margin-bottom: 12px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
}

.leader-item .rank {
  width: 24px;
  height: 24px;
  background: var(--yellow);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.leader-item .name {
  flex: 1;
}

.leader-item .score {
  font-weight: 700;
  color: var(--purple);
}

/* Main Game Area */
.main-game-area {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-header-bar {
  background: linear-gradient(135deg, var(--purple-l) 0%, var(--blue-l) 100%);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-header-bar h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 22px;
}

.score-display {
  display: flex;
  gap: 12px;
}

.score-pill, .lives-pill {
  background: var(--white);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}

.score-pill strong, .lives-pill strong {
  color: var(--purple);
  font-size: 18px;
}

/* Game Container */
.game-container {
  position: relative;
  flex: 1;
  min-height: 500px;
  background: #87CEEB;
}

.game-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Start Overlay */
.start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.start-content {
  background: var(--white);
  padding: 40px;
  border-radius: var(--radius);
  text-align: center;
  max-width: 400px;
}

.start-content h3 {
  font-family: 'Baloo 2', cursive;
  font-size: 32px;
  margin-bottom: 16px;
}

.start-content p {
  color: var(--muted);
  margin-bottom: 24px;
}

.start-overlay.hidden {
  display: none;
}

/* Side Panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.camera-section, .quick-stats {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 16px;
}

.camera-section h4, .quick-stats h4 {
  font-family: 'Baloo 2', cursive;
  font-size: 14px;
  margin-bottom: 12px;
}

.camera-container {
  position: relative;
  aspect-ratio: 4/3;
  background: #1e2a4a;
  border-radius: 12px;
  overflow: hidden;
}

.camera-video {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.tracking-info {
  margin-top: 12px;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 12px;
}

.tracking-info p {
  color: var(--muted);
  margin-bottom: 4px;
}

.tracking-info span {
  color: var(--text);
  font-weight: 600;
}

/* Quick Stats */
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row span:last-child {
  font-weight: 700;
  color: var(--purple);
}

/* Game Over Overlay */
.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.game-over-content {
  background: var(--white);
  padding: 40px;
  border-radius: var(--radius);
  text-align: center;
}

.game-over-content h3 {
  font-family: 'Baloo 2', cursive;
  font-size: 36px;
  color: var(--red);
  margin-bottom: 16px;
}

.final-score {
  font-size: 24px;
  margin-bottom: 24px;
}

.final-score strong {
  color: var(--purple);
  font-size: 32px;
}

/* Modal for Learn Page */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius);
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--purple-l) 0%, var(--blue-l) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 24px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
}

.game-area {
  flex: 1;
  min-height: 500px;
  position: relative;
}

/* Camera / connection status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #f1f5f9;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.status-badge.active {
  background: var(--green-l);
  color: var(--green);
}

/* Stat pills for game score bar */
.stat-pill {
  background: var(--white);
  border: 2px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  margin-right: 8px;
}

.stat-pill strong {
  color: var(--purple);
  font-size: 17px;
}

/* ── Play Zone Modal ─────────────────────────────────────────────────────────── */

.play-modal-content {
  max-width: 1200px;
  width: 95vw;
  height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Override default modal-content max-height so height works */
.play-modal-content.modal-content {
  max-height: none;
}

.play-modal-header {
  background: linear-gradient(135deg, var(--purple-l) 0%, var(--blue-l) 100%);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.play-modal-header h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 20px;
  white-space: nowrap;
  margin-right: 16px;
}

.play-modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.play-btn {
  padding: 6px 14px !important;
  font-size: 13px !important;
  height: 34px;
  white-space: nowrap;
}

.play-difficulty {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  cursor: pointer;
  height: 34px;
}

.play-difficulty.hidden {
  display: none;
}

/* Game canvas area */
.play-game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #1e2a4a;
  min-height: 400px; /* Ensure visible game area */
}

.play-game-area canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Game Over overlay */
.play-gameover {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.play-gameover.hidden {
  display: none;
}

.play-gameover-box {
  background: var(--white);
  padding: 40px 48px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.play-gameover-box h3 {
  font-family: 'Baloo 2', cursive;
  font-size: 36px;
  color: var(--red);
  margin-bottom: 12px;
}

.play-gameover-box .final-score {
  font-size: 22px;
  margin-bottom: 24px;
}

/* Camera strip at bottom */
.play-camera-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #0f172a;
  padding: 8px 16px;
  min-height: 80px;
}

.play-camera-preview {
  position: relative;
  width: 120px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  background: #1e2a4a;
  flex-shrink: 0;
}

.play-camera-preview video,
.play-camera-preview canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.play-tracking-text {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.5;
}

/* ── Fullscreen overrides ────────────────────────────────────────────────────── */

.play-modal-content:fullscreen,
.play-modal-content:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
}


/* ── Play Zone page — game cards ─────────────────────────────────────────────── */

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.game-card-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  background: var(--white);
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: inherit;
  color: var(--text);
}

.game-card-large:hover {
  border-color: var(--purple);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.18);
}

.game-card-large .game-emoji {
  font-size: 48px;
  line-height: 1;
}

.game-card-large .game-name {
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  font-size: 16px;
}

.game-card-large .game-desc {
  font-size: 12px;
  color: var(--muted);
}

.game-card-large .difficulty {
  font-size: 13px;
  margin-top: 4px;
}
