* { box-sizing: border-box; }
body { margin: 0; background: #e6e6e6; font-family: Georgia, serif; min-height: 100vh; }

.container {
  display: flex;
  min-height: 100vh;
  max-width: 1200px;
  margin: 20px auto;
  background: #000;
  box-shadow: 0 0 0 6px rgba(0,0,0,0.05) inset;
}

/* --- LEFT PANEL --- */
.text-area { width: 36%; padding: 42px 44px; color: #fff; overflow-y: auto; font-family: 'Courier New', Courier, monospace; line-height: 1.6; }
.text-area h1 { font-size: 22px; color: #bfbfbf; font-weight: normal; margin-top: 0; }

.instruction-box { 
  border: 1px solid rgba(255,255,255,0.18); 
  padding: 15px; 
  background: rgba(255,255,255,0.05); 
  font-family: 'Courier New', Courier, monospace; 
  color: #dcdcdc; 
  font-size: 14px; 
}

.desktop-back-link { color: #fff; text-decoration: none; display: inline-block; margin-top: 18px; font-family: 'Courier New', Courier, monospace; }

/* --- RIGHT PANEL --- */
.game-frame { 
  width: 64%; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  padding: 20px; 
  background: #000;
}

/* recording indicator */
#rec-indicator {
  position: absolute;
  top: 18px;
  right: 18px;
  background: #b71c1c;
  color: #fff;
  padding: 6px 10px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  border-radius: 4px;
  z-index: 50;
}

/* --- DESKTOP CANVAS SIZE (Fixed Smallness) --- */
.game-canvas { 
  line-height: 0; 
  border: 10px solid #3b6b6b; 
  background: #0b0b0b;
  display: inline-block;
  margin-bottom: 20px;
  /* Desktop fixed size */
  width: 600px; 
  height: 600px;
}

.game-canvas canvas {
  display: block; 
  width: 100% !important;
  height: 100% !important;
  /* Allow vertical scrolling (pan-y) when touching the canvas on mobile */
  touch-action: pan-y;
}

.mobile-top-instructions, .mobile-rec { display: none; }

/* --- CONTROLS --- */
.save-controls { display: flex; gap: 15px; margin-top: 10px; }
#player-name { background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); color: #bfbfbf; padding: 12px; width: 180px; text-align: center; font-family: 'Courier New', Courier, monospace; }
#save-btn { background: rgba(59, 107, 107, 0.25); border: 1px solid rgba(59, 107, 107, 0.8); color: #dcdcdc; padding: 12px 24px; cursor: pointer; font-family: 'Courier New', Courier, monospace; }
#save-btn[disabled] { opacity: 0.3; }

/* --- RECORDINGS --- */
.recordings-section h3 { font-family: 'Courier New', Courier, monospace; font-size: 15px; color: #bfbfbf; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px; font-weight: normal; }
#tunes-list-desktop, #tunes-list-mobile { padding: 0; list-style: none; font-family: 'Courier New', Courier, monospace; color: #dcdcdc; font-size: 14px; }
#tunes-list-desktop li, #tunes-list-mobile li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; cursor: pointer; }

/* --- MOBILE --- */
.enter-btn, .back-mobile { display: none; }

@media (max-width: 920px), (pointer: coarse) {
  .container { flex-direction: column; height: auto; margin: 0; }
  .text-area { width: 100%; padding: 20px; }
  .desktop-sidebar-instructions, .desktop-rec, .desktop-back-link { display: none; }
  
  .game-frame { width: 100%; padding: 20px; }
  .mobile-top-instructions { display: block; order: 1; width: 92%; margin-bottom: 20px; }
  
  /* Reset size for mobile screens */
  .game-canvas { 
    order: 2;
    /* cap to viewport width but keep square aspect */
    width: min(92vw, 500px);
    aspect-ratio: 1 / 1;
    height: auto;
    max-width: 92vw;
  }
  
  .enter-btn { display: block; order: 3; margin: 15px 0; padding: 12px; background: #222; color: #fff; width: 180px; border: 1px solid #444; font-family: 'Courier New', Courier, monospace; }
  .save-controls { display: flex; flex-direction: column; order: 4; width: 92%; gap: 10px; }
  #player-name, #save-btn { width: 100%; }
  
  .mobile-rec { display: block; order: 5; width: 92%; margin-top: 25px; }
  .back-mobile { display: block; order: 6; color: #fff; margin: 30px 0; text-decoration: none; text-align: center; border-top: 1px solid #333; padding-top: 15px; width: 92%; font-family: 'Courier New', Courier, monospace; }
}

.controls { display: none; }
