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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  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: 8px 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: 20px;
  font-weight: bold;
  color: #ffd700;
  min-width: 40px;
}

.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;
}

.btn-secondary {
  background: rgba(255,255,255,0.15);
}

.btn-home {
  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);
}

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

/* Hanoi Board */
.hanoi-board {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 0 10px;
  height: 65vh;
  max-height: 450px;
}

.peg-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  width: 30%;
  position: relative;
  height: 100%;
  justify-content: flex-end;
  transition: transform 0.15s;
}

.peg-container:active {
  transform: scale(0.98);
}

.peg-container.selected {
  filter: brightness(1.3);
}

.peg-container.selected .peg-rod {
  background: linear-gradient(180deg, #ffd700, #ff8c00);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.peg-container.hint {
  animation: hintPulse 0.6s ease-in-out 2;
}

@keyframes hintPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
}

.peg-label {
  position: absolute;
  bottom: -22px;
  font-size: 14px;
  font-weight: bold;
  color: rgba(255,255,255,0.5);
}

.peg-rod {
  width: 8px;
  background: linear-gradient(180deg, #8b7355, #654321);
  border-radius: 4px 4px 0 0;
  position: absolute;
  bottom: 20px;
  z-index: 1;
  transition: background 0.3s, box-shadow 0.3s;
}

.peg-base {
  width: 90%;
  height: 20px;
  background: linear-gradient(180deg, #8b7355, #654321);
  border-radius: 10px;
  z-index: 2;
  flex-shrink: 0;
}

.discs-stack {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  z-index: 3;
  position: absolute;
  bottom: 20px;
  width: 100%;
}

.disc {
  height: 28px;
  border-radius: 14px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}

.disc.lifting {
  transform: translateY(-20px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.disc:first-child {
  /* top disc highlight */
}

/* Disc colors */
.disc-1 { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.disc-2 { background: linear-gradient(135deg, #ffa502, #e67e22); }
.disc-3 { background: linear-gradient(135deg, #ffd32a, #f0c419); }
.disc-4 { background: linear-gradient(135deg, #7bed9f, #2ed573); }
.disc-5 { background: linear-gradient(135deg, #70a1ff, #1e90ff); }
.disc-6 { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
.disc-7 { background: linear-gradient(135deg, #fd79a8, #e84393); }
.disc-8 { background: linear-gradient(135deg, #fdcb6e, #f39c12); }

/* Action buttons row */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 30px;
  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;
}

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

/* 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: 30px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.overlay-title {
  font-size: 28px;
  margin-bottom: 6px;
}

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

/* Difficulty Selection */
.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.difficulty-btn {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  text-align: center;
}

.difficulty-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateY(-2px);
}

.difficulty-btn.selected {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
}

.difficulty-btn .disc-count {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 4px;
}

.difficulty-btn .disc-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.btn-start {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a1a2e;
  border: none;
  padding: 14px 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);
}

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

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

.complete-rating {
  font-size: 16px;
  margin: 12px 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
}

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

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

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

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

.new-record {
  color: #ffd700;
  font-size: 20px;
  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: 16px; }
  .disc { height: 24px; border-radius: 12px; font-size: 12px; }
  .peg-base { height: 16px; }
  .hanoi-board { height: 55vh; }
  .overlay-content { padding: 20px; }
}

@media (min-height: 800px) {
  .hanoi-board { max-height: 500px; }
}
