* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { 
  height: 100%; 
  width: 100%; 
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif; 
  background: #0a0e1a; 
  color: #fff; 
}

#game-container {
  position: relative;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  touch-action: none;
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: none;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 8px;
  z-index: 100;
}

.mobile-btn {
  appearance: none;
  border: 2px solid rgba(100,149,237,0.5);
  background: rgba(30,41,59,0.8);
  color: #fff;
  font-size: 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.mobile-btn:active {
  background: rgba(100,149,237,0.6);
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

.mobile-btn[data-direction="up"] {
  grid-column: 2;
  grid-row: 1;
}

.mobile-btn[data-direction="down"] {
  grid-column: 2;
  grid-row: 3;
}

.mobile-btn[data-direction="left"] {
  grid-column: 1;
  grid-row: 2;
}

.mobile-btn[data-direction="right"] {
  grid-column: 3;
  grid-row: 2;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: grid;
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 200ms ease;
  opacity: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
}
.overlay.visible {
  pointer-events: auto;
  opacity: 1;
}

.overlay .panel {
  background: linear-gradient(135deg, rgba(15,23,42,0.95) 0%, rgba(30,41,59,0.95) 100%);
  border: 2px solid rgba(100,149,237,0.3);
  padding: 32px 40px;
  border-radius: 16px;
  text-align: center;
  min-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 1px rgba(100,149,237,0.5);
}

.overlay h1 { 
  font-size: 42px; 
  margin-bottom: 12px; 
  background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  letter-spacing: 1px;
}

.overlay h2 { 
  font-size: 32px; 
  margin-bottom: 16px; 
  color: #6495ed;
  font-weight: 600;
}

.overlay p { 
  margin-bottom: 20px; 
  color: #cbd5e1; 
  font-size: 15px;
}

.difficulty-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.diff-btn {
  appearance: none;
  border: 2px solid rgba(100,149,237,0.3);
  background: rgba(30,41,59,0.4);
  color: #94a3b8;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 200ms ease;
}

.diff-btn:hover {
  border-color: rgba(100,149,237,0.6);
  background: rgba(30,41,59,0.6);
  color: #e2e8f0;
}

.diff-btn.active {
  background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%);
  border-color: #6495ed;
  color: #fff;
  box-shadow: 0 4px 12px rgba(100,149,237,0.4);
}

.primary-btn {
  appearance: none;
  border: 0;
  background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%);
  color: #fff;
  padding: 14px 32px;
  margin: 8px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 6px 20px rgba(100,149,237,0.3);
  transition: all 200ms ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(100,149,237,0.5);
}

.overlay button:not(.primary-btn):not(.diff-btn) {
  appearance: none;
  border: 2px solid rgba(100,149,237,0.3);
  background: rgba(30,41,59,0.5);
  color: #cbd5e1;
  padding: 10px 20px;
  margin: 6px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 200ms ease;
}

.overlay button:not(.primary-btn):not(.diff-btn):hover {
  border-color: rgba(100,149,237,0.6);
  background: rgba(30,41,59,0.7);
  color: #fff;
}

.hint { 
  font-size: 13px; 
  color: #64748b; 
  margin-top: 16px;
}

@media (max-width: 600px) {
  .overlay .panel { 
    padding: 24px 28px; 
    min-width: 280px; 
  }
  .overlay h1 { font-size: 36px; }
  .difficulty-selector { flex-wrap: wrap; }
}