:root {
  --bg-start: #e0f7ff;
  --bg-end: #f7ffe0;
  --primary: #1e88e5;
  --secondary: #43a047;
  --accent: #fdd835;
  --danger: #e53935;
  --tile-size: 44px;
  --board-width: 10;
  --board-height: 10;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: #123;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border-bottom: 3px solid rgba(30, 136, 229, 0.15);
  position: sticky;
  top: 0;
  z-index: 5;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--primary);
}

.game-info {
  display: flex;
  align-items: center;
  gap: 18px;
  font-weight: 600;
}

.info-item {
  background: #f4f8ff;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(30, 136, 229, 0.2);
}

.info-item.difficulty select {
  margin-left: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 2px solid rgba(30, 136, 229, 0.25);
  background: #ffffff;
  font-weight: 700;
}

.app-main {
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(var(--board-width), var(--tile-size));
  grid-template-rows: repeat(var(--board-height), var(--tile-size));
  gap: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(18, 51, 68, 0.15);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  touch-action: manipulation;
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: grid;
  place-items: center;
  border-radius: 10px;
  user-select: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.1rem;
  border: 2px solid rgba(0,0,0,0.08);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease, opacity 200ms ease;
}

.tile-hidden {
  background: linear-gradient(145deg, #cce6ff, #b3daff);
  color: transparent;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}
.tile-hidden:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 10px rgba(0,0,0,0.12);
}

.tile-revealed {
  background: #fff;
  color: #123;
  cursor: default;
  box-shadow: inset 0 2px 0 rgba(0,0,0,0.06);
  animation: pop-in 200ms ease;
}

.tile-flagged::after {
  content: "🚩";
  font-size: 1.1rem;
}

.tile-mine::after {
  content: "💣";
  font-size: 1.2rem;
}

.tile-correct {
  animation: pulse-correct 500ms ease;
}
.tile-wrong {
  animation: shake 400ms ease;
}

@keyframes pop-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse-correct {
  0% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.5); }
  100% { box-shadow: 0 0 0 14px rgba(67, 160, 71, 0); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* Warna angka 1-8 */
.num-1 { color: #1e88e5; }
.num-2 { color: #43a047; }
.num-3 { color: #e53935; }
.num-4 { color: #8e24aa; }
.num-5 { color: #6d4c41; }
.num-6 { color: #00897b; }
.num-7 { color: #212121; }
.num-8 { color: #757575; }

.tile-number-glow {
  box-shadow: 0 0 0 0 rgba(30, 136, 229, 0.0);
  animation: number-glow 800ms ease;
}

@keyframes number-glow {
  0% { box-shadow: 0 0 0 0 rgba(30,136,229,0.6); }
  100% { box-shadow: 0 0 0 16px rgba(30,136,229,0); }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal-overlay.show { display: flex; }

.modal {
  width: min(680px, 92vw);
  background: #ffffff;
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.2);
  border: 2px solid rgba(18, 51, 68, 0.1);
}

.modal h3 {
  margin: 0 0 12px;
  color: #123;
}

.answer-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.answer-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid rgba(30, 136, 229, 0.25);
  background: #f5faff;
  color: #123;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}
.answer-btn:hover {
  background: #e9f4ff;
  transform: translateY(-1px);
}
.answer-btn.selected {
  border-color: var(--primary);
  background: #d8ecff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  background: #efefef;
  color: #123;
  font-weight: 800;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(145deg, #42a5f5, #1e88e5);
  color: white;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Overlay Hasil */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 25;
}
.result-overlay.show { display: flex; }

.result-box {
  background: white;
  border-radius: 14px;
  padding: 20px 18px 16px;
  width: min(520px, 92vw);
  text-align: center;
  box-shadow: 0 18px 40px rgba(0,0,0,0.25);
  border: 2px solid rgba(18, 51, 68, 0.1);
}

.result-box h2 {
  margin: 0 0 12px;
  font-size: 1.6rem;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  justify-items: center;
  margin-bottom: 14px;
  color: #123;
  font-weight: 700;
}

.leaderboard {
  background: #f9fbff;
  border: 1px solid rgba(30, 136, 229, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
}
.leaderboard h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.leaderboard ol {
  margin: 0;
  padding-left: 18px;
}
.leaderboard li {
  margin: 4px 0;
}

/* Responsif */
@media (max-width: 560px) {
  :root { --tile-size: 38px; }
  .app-header h1 { font-size: 1.3rem; }
}
@media (max-width: 400px) {
  :root { --tile-size: 34px; }
}

