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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1040 40%, #0d1b3e 70%, #0a0e27 100%);
  color: #e0e0e0;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 45% 45%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 60% 30%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 25% 70%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 75% 55%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 95% 90%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 40% 95%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 55% 75%, rgba(255,255,255,0.7), transparent);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  max-width: 560px;
  width: 100%;
}

.title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  letter-spacing: 4px;
}

.subtitle {
  font-size: 0.85rem;
  color: #8888aa;
  margin-bottom: 20px;
}

.info-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 12px;
}

.info-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.info-label {
  font-size: 0.85rem;
  color: #8888aa;
}

.info-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd700;
  transition: transform 0.2s;
  display: inline-block;
}

.info-value.bump {
  animation: bump 0.3s ease;
}

@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.hint {
  font-size: 0.85rem;
  color: #aaaacc;
  margin-bottom: 16px;
  min-height: 1.2em;
  transition: color 0.3s;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.cell:active {
  transform: scale(0.95);
}

.cell .symbol {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 4px;
  transition: transform 0.3s;
}

.cell .name {
  font-size: 0.8rem;
  color: #aaaacc;
  transition: color 0.3s;
}

.cell .badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s;
}

/* Cleared state */
.cell.cleared {
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.08);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.15), inset 0 0 15px rgba(255, 215, 0, 0.05);
}

.cell.cleared .symbol {
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.cell.cleared .name {
  color: #ffd700;
}

.cell.cleared .badge {
  opacity: 1;
}

/* Selected state */
.cell.selected {
  border-color: rgba(100, 180, 255, 0.8);
  background: rgba(100, 180, 255, 0.12);
  box-shadow: 0 0 20px rgba(100, 180, 255, 0.3), inset 0 0 15px rgba(100, 180, 255, 0.08);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(100, 180, 255, 0.3), inset 0 0 15px rgba(100, 180, 255, 0.08); }
  50% { box-shadow: 0 0 30px rgba(100, 180, 255, 0.5), inset 0 0 20px rgba(100, 180, 255, 0.12); }
}

/* Hint for same row/col cells when one is selected */
.cell.swap-hint {
  border-color: rgba(100, 180, 255, 0.3);
  background: rgba(100, 180, 255, 0.05);
}

/* Swap animation */
.cell.swapping {
  animation: swapFlash 0.4s ease;
}

@keyframes swapFlash {
  0% { transform: scale(1); }
  30% { transform: scale(0.85); opacity: 0.6; }
  70% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

/* Disabled state */
.cell.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Edit mode */
.grid.edit-mode .cell {
  border-color: rgba(180, 100, 255, 0.15);
  background: rgba(180, 100, 255, 0.03);
}

.grid.edit-mode .cell:hover {
  background: rgba(180, 100, 255, 0.1);
  border-color: rgba(180, 100, 255, 0.35);
}

.cell.edit-selected {
  border-color: rgba(180, 100, 255, 0.8);
  background: rgba(180, 100, 255, 0.12);
  box-shadow: 0 0 20px rgba(180, 100, 255, 0.3), inset 0 0 15px rgba(180, 100, 255, 0.08);
  animation: editPulse 1.5s ease-in-out infinite;
}

@keyframes editPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(180, 100, 255, 0.3), inset 0 0 15px rgba(180, 100, 255, 0.08); }
  50% { box-shadow: 0 0 30px rgba(180, 100, 255, 0.5), inset 0 0 20px rgba(180, 100, 255, 0.12); }
}

.btn-edit-active {
  background: rgba(180, 100, 255, 0.15) !important;
  border-color: rgba(180, 100, 255, 0.5) !important;
  color: #c080ff !important;
}

.btn-edit-active:hover {
  background: rgba(180, 100, 255, 0.25) !important;
}

/* Actions */
.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn {
  padding: 10px 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ccccee;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:disabled:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Overlay & Modal */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: linear-gradient(135deg, #1a1040, #0d1b3e);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  transform: scale(0.8);
  transition: transform 0.4s;
}

.overlay.active .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 8px;
}

.modal-text {
  font-size: 0.9rem;
  color: #aaaacc;
  margin-bottom: 24px;
}

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

.modal .btn:hover {
  background: rgba(255, 215, 0, 0.25);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 16px 12px;
  }
  .title {
    font-size: 1.5rem;
  }
  .cell .symbol {
    font-size: 1.6rem;
  }
  .cell .name {
    font-size: 0.7rem;
  }
  .grid {
    gap: 6px;
  }
}
