body {
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
      sans-serif;
    background: #000000;
    color: #f0f0f0;
    overflow: hidden;
  }
  
  /* --- START SCREEN --- */
  #startScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 1;
    transition: opacity 0.5s ease-out;
  }
  #startScreen.hidden {
    opacity: 0;
    pointer-events: none;
  }
  #startScreen h1 {
    font-size: 48px;
    font-weight: 300;
    letter-spacing: 2px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }
  #startScreen .instructions {
    max-width: 400px;
    text-align: center;
    line-height: 1.6;
    color: #aaaaaa;
    padding: 0 15px;
  }
   #startScreen .instructions .mobile-controls {
    display: none;
   }
  #startScreen .instructions kbd {
    background: #333;
    border: 1px solid #555;
    padding: 2px 6px;
    font-family: monospace;
  }
  
  .ui-container {
    display: none; /* Hidden by default */
  }
  .ui-container.active {
    display: block;
  }
  
  .ui-block {
    position: absolute;
    background: rgba(20, 20, 20, 0.7);
    padding: 15px;
    text-align: center;
    z-index: 100;
    opacity: 0.6;
    transition: opacity 0.3s ease-in-out;
    border-radius: 4px;
  }
  
  .ui-block.is-active {
    opacity: 1;
  }
  
  .controls-top-left {
    top: 20px;
    left: 20px;
  }
  
  .game-header {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    backdrop-filter: none;
    opacity: 0.8;
  }
  
  .controls-top-right {
    top: 20px;
    right: 20px;
  }
  
  /* New wrapper for all bottom controls */
  .bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none; /* Let clicks pass through the empty space */
  }

  /* Bottom control groups are now flex items, not positioned */
  .controls-bottom-left,
  .controls-bottom-right,
  .layer-controls {
    pointer-events: auto; /* Re-enable clicks on the controls themselves */
  }

  .controls-bottom-left,
  .controls-bottom-right {
    display: flex;
    gap: 10px;
  }
  
  .level-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
  }
  
  .queens-counter {
    font-size: 18px;
    font-weight: 500;
    color: #f0f0f0;
  }
  
  .btn {
    background: transparent;
    border: 1px solid #cccccc;
    color: #cccccc;
    padding: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 0px 0px #f0f0f0;
  }
  .btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
  }
  .btn.icon-only {
    font-size: 20px;
  }
  
  .btn:hover:not(:disabled) {
    color: #ffffff;
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px 0px #ffffff;
  }
  
  .btn.active {
    color: #ffffff;
    border-color: #00ffff;
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 10px 0px #00ffff;
  }

  .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: transparent;
    color: #777777;
    border-color: #777777;
  }
  
  .next-level-btn {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
    color: #4caf50;
  }
  
  .next-level-btn:hover:not(:disabled) {
    background: #4caf50;
    color: white;
    box-shadow: 0 0 10px 0px #4caf50;
  }
  
  .level-progress {
    font-size: 14px;
    margin-bottom: 5px;
    color: #cccccc;
  }
  
  .personal-best,
  #targetQueens {
    font-size: 14px;
    font-weight: 600;
    color: #daa520; /* GoldenRod */
  }
  
  .layer-controls {
    display: grid;
    grid-template-areas:
      ". up ."
      "left reset right"
      ". down .";
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    text-align: center;
    background: rgba(20, 20, 20, 0.7);
    padding: 15px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    z-index: 100;
  }
  .layer-controls.visible {
    opacity: 1;
    pointer-events: auto;
  }
  .layer-controls button {
    background: #1a1a1a;
    border: 1px solid #cccccc;
    color: #cccccc;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 28px;
  }
  .layer-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: #ffffff;
  }
  .layer-controls .up {
    grid-area: up;
  }
  .layer-controls .down {
    grid-area: down;
  }
  .layer-controls .left {
    grid-area: left;
  }
  .layer-controls .right {
    grid-area: right;
  }
  .layer-controls .reset {
    grid-area: reset;
  }
  
  .level-navigation {
    display: none; /* Hidden permanently as it was for creative mode */
  }
  
  #conflict-indicators {
    display: flex;
    gap: 4px;
    height: 20px;
    margin-top: 8px;
    justify-content: center;
    min-height: 20px;
  }
  .conflict-indicator {
    width: 16px;
    height: 16px;
    color: #dc143c; /* Crimson */
    filter: drop-shadow(0 0 3px #dc143c);
  }
  
  #canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
    display: block;
    cursor: grab;
  }
  #canvas.dragging {
    cursor: grabbing;
  }
  
  #notification-bar {
    position: fixed;
    top: -100px; /* Start hidden above the screen */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(76, 175, 80, 0.95);
    color: white;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    z-index: 200;
    text-align: center;
    transition: top 0.5s ease-in-out;
    pointer-events: none;
    border-radius: 4px;
  }
  #notification-bar.show {
    top: 20px; /* Default position for desktop */
  }

/* --- RESPONSIVE STYLES FOR MOBILE --- */
@media (max-width: 768px) {
  .ui-block {
    padding: 10px;
  }

  .game-header {
    top: 15px;
    width: auto; 
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .controls-top-right {
    top: 130px; 
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: calc(100% - 40px);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    padding: 0;
  }

  .bottom-bar {
    padding: 15px;
  }

  #dPadToggleBtn {
      display: flex;
  }

  .layer-controls {
    background: none; 
    padding: 10px;
  }

   .layer-controls button {
     width: 40px; 
     height: 40px;
     font-size: 22px;
   }
  
  .controls-bottom-right {
    gap: 5px;
    flex-direction: column; 
  }
  
  .btn {
    width: 48px; 
    height: 48px;
  }
  .btn svg {
    width: 24px;
    height: 24px;
  }
  
  #notification-bar.show {
    top: 80px;
  }
}