:root {
  --bg-color: #1a1a2e;
  --panel-bg: #16213e;
  --cell-size: 30px;
  --cell-gap: 2px;
  --cell-hidden: #0f3460;
  --cell-revealed: #e94560;
  --text-color: #f1f1f1;
  --highlight: #533483;
  --accent: #e94560;

  --c1: #4285F4;
  --c2: #34A853;
  --c3: #EA4335;
  --c4: #9C27B0;
  --c5: #FF6D00;
  --c6: #00BCD4;
  --c7: #424242;
  --c8: #9E9E9E;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  max-width: 800px;
}

.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  box-sizing: border-box;
}

.title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
}

.game-wrapper {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 10;
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: rgba(0,0,0,0.3);
  padding: 10px 20px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.05);
  box-sizing: border-box;
}

.counter {
  font-family: 'Roboto Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0,0,0,0.5);
  padding: 5px 10px;
  border-radius: 4px;
  min-width: 60px;
  text-align: center;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

.face-btn {
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
  padding: 0;
  line-height: 1;
}

.face-btn:active {
  transform: scale(0.9);
}

.grid-container {
  display: grid;
  gap: 1px;
  background: rgba(0,0,0,0.5);
  padding: 4px;
  border-radius: 4px;
  touch-action: none;
  max-width: 100%;
  overflow: auto;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--cell-hidden);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  box-shadow: inset 2px 2px 0px rgba(255,255,255,0.1), inset -2px -2px 0px rgba(0,0,0,0.3);
}

.cell:hover {
  filter: brightness(1.1);
}

.cell.revealed {
  background: #f0f0f0;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.2);
  cursor: default;
}

.cell.flagged {
  font-size: 16px;
}

.cell.mine {
  background: var(--accent);
  color: #fff;
}

.cell.incorrect-flag {
  background: #f0f0f0;
  position: relative;
}

.cell.incorrect-flag::after {
  content: '❌';
  position: absolute;
  font-size: 20px;
  color: red;
}

/* Numbers Colors */
.cell.n1 { color: var(--c1); }
.cell.n2 { color: var(--c2); }
.cell.n3 { color: var(--c3); }
.cell.n4 { color: var(--c4); }
.cell.n5 { color: var(--c5); }
.cell.n6 { color: var(--c6); }
.cell.n7 { color: var(--c7); }
.cell.n8 { color: var(--c8); }

.controls-bottom {
  display: flex;
  gap: 20px;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}

.difficulty-select {
  display: flex;
  gap: 5px;
  background: rgba(0,0,0,0.3);
  padding: 5px;
  border-radius: 8px;
}

.diff-btn {
  background: transparent;
  border: none;
  color: #888;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.diff-btn.active {
  background: var(--highlight);
  color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.action-btn {
  background: var(--highlight);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}

.action-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
}

#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* Animations */
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.cell.revealed {
  animation: pop 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (max-width: 600px) {
  .title { font-size: 1.5rem; }
  .counter { font-size: 1.2rem; min-width: 50px; }
  .diff-btn { padding: 4px 8px; font-size: 0.7rem; }
  .cell { font-size: 14px; }
  :root { --cell-size: 24px; }
  .game-wrapper { padding: 10px; }
}

/* New Record Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(5px);
  transition: opacity 0.3s;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--panel-bg);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--accent);
  animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 300px;
}

.modal-content h2 {
  color: var(--accent);
  margin: 0;
  font-size: 1.8rem;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.3);
}

.record-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0,0,0,0.2);
  padding: 1rem;
  border-radius: 8px;
}

.record-label {
  font-size: 0.9rem;
  color: #888;
  font-weight: 600;
}

.record-value {
  font-family: 'Roboto Mono', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
}
