* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  min-height: 100vh;
  overflow: hidden;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

.game-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 12px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  flex-shrink: 0;
}

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

.score-item {
  text-align: center;
}

.score-label {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-value {
  font-size: 18px;
  font-weight: bold;
  color: #ffd700;
  min-width: 36px;
}

.control-buttons {
  display: flex;
  gap: 6px;
}

.btn {
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  background: rgba(255,255,255,0.15);
}

.btn:hover { transform: scale(1.05); background: rgba(255,255,255,0.25); }
.btn:active { transform: scale(0.95); }

/* Rules */
.game-rules-bg {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  line-height: 1.6;
  pointer-events: none;
  flex-shrink: 0;
  padding: 2px 0;
}

/* Game Area */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  min-height: 0;
  padding-top: 4px;
}

/* Board */
.sokoban-board {
  display: grid;
  gap: 1px;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
}

.cell {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  position: relative;
  transition: background 0.15s;
}

.cell-floor { background: #2a2a4a; }
.cell-wall { background: #4a3728; border: 1px solid #5c4433; border-radius: 3px; }
.cell-target { background: #2a2a4a; }
.cell-target::after {
  content: '';
  width: 35%;
  height: 35%;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.5);
  position: absolute;
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.4);
}
.cell-void { background: transparent; }

.cell-player {
  font-size: 1.6em;
  z-index: 2;
  animation: playerBreathe 2s ease-in-out infinite;
}

@keyframes playerBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.cell-box {
  font-size: 1.4em;
  z-index: 2;
  transition: transform 0.15s;
}

.cell-box-on-target {
  font-size: 1.4em;
  z-index: 2;
  filter: brightness(1.3);
  animation: boxGlow 1.5s ease-in-out infinite;
}

@keyframes boxGlow {
  0%, 100% { filter: brightness(1.3); }
  50% { filter: brightness(1.6); }
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-shrink: 0;
}

.btn-action {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s;
}

.btn-action:hover { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
.btn-action:active { transform: translateY(0); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

/* D-pad for mobile */
.dpad {
  display: grid;
  grid-template-areas:
    '. up .'
    'left . right'
    '. down .';
  gap: 4px;
  margin-top: 10px;
  flex-shrink: 0;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active { background: rgba(255,255,255,0.35); transform: scale(0.92); }
.dpad-up { grid-area: up; }
.dpad-down { grid-area: down; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }

/* Overlay */
.game-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

.overlay-content {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border-radius: 20px;
  padding: 25px;
  text-align: center;
  max-width: 480px;
  width: 95%;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-height: 85vh;
  overflow-y: auto;
}

.overlay-title {
  font-size: 26px;
  margin-bottom: 4px;
}

.overlay-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 16px;
}

/* Pack tabs */
.pack-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.pack-tabs::-webkit-scrollbar { display: none; }

.pack-tab {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  min-width: 70px;
}

.pack-tab:hover { background: rgba(255,255,255,0.15); }

.pack-tab.active {
  background: rgba(255,215,0,0.15);
  border-color: #ffd700;
}

.pack-tab-name {
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.pack-tab-count {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.pack-tab.active .pack-tab-count {
  color: #ffd700;
}

/* Level grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 4px;
}

.level-btn {
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  position: relative;
}

.level-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,215,0,0.5); }
.level-btn.selected { background: rgba(255,215,0,0.15); border-color: #ffd700; }
.level-btn.completed { background: rgba(46,213,115,0.15); border-color: #2ed573; }
.level-btn .check {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 9px;
  color: #2ed573;
  line-height: 1;
}

.btn-start {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a1a2e;
  border: none;
  padding: 12px 40px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-start:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(255,215,0,0.4); }

.credit {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* Complete */
.complete-stats {
  margin: 12px 0;
}

.complete-stats p {
  font-size: 15px;
  margin: 5px 0;
  color: rgba(255,255,255,0.8);
}

.complete-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.complete-buttons .btn-start { font-size: 14px; padding: 11px; }

.btn-secondary-full {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 11px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary-full:hover { background: rgba(255,255,255,0.2); }

.new-record {
  color: #ffd700;
  font-size: 18px;
  animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Responsive */
@media (max-width: 400px) {
  .score-panel { gap: 8px; }
  .score-value { font-size: 15px; }
  .dpad-btn { width: 48px; height: 48px; font-size: 18px; }
  .overlay-content { padding: 18px; }
}
