/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: #1a1a2e;
  background-image: radial-gradient(circle at 30% 70%, #16213e 0%, #1a1a2e 60%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #fff;
  user-select: none;
  overflow-x: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff; font-family: 'Nunito', sans-serif; flex-shrink: 0;
}
.btn-back {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 0.85rem;
  background: rgba(255,255,255,0.2); padding: 0.3rem 0.7rem; border-radius: 999px;
  transition: background 0.2s; white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,0.35); }
.game-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.stats { display: flex; gap: 0.8rem; font-size: 0.9rem; font-weight: 700; opacity: 0.95; white-space: nowrap; }

.controls-bar {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: 0.5rem 1rem; background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
  flex-wrap: wrap; flex-shrink: 0;
}
.control-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }

.btn {
  padding: 0.35rem 1rem; border: none; border-radius: 999px; font-family: 'Nunito', sans-serif;
  font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.96); }
.btn-new { background: #e94560; color: #fff; }
.btn-new:hover { opacity: 0.88; }
.btn-hint { background: rgba(255,255,255,0.15); color: #fff; border: 2px solid rgba(255,255,255,0.25); }
.btn-hint:hover { background: rgba(255,255,255,0.25); }
.btn-shuffle { background: rgba(255,255,255,0.15); color: #fff; border: 2px solid rgba(255,255,255,0.25); }
.btn-shuffle:hover { background: rgba(255,255,255,0.25); }
.btn-orange { background: #e94560; color: #fff; padding: 0.5rem 1.5rem; font-size: 1rem; border: none; border-radius: 999px; font-family: 'Nunito', sans-serif; font-weight: 700; cursor: pointer; }
.btn-orange:hover { opacity: 0.88; }

.game-container {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 0.5rem; overflow: auto;
}

.mahjong-board {
  position: relative;
  margin: 0 auto;
}

.mj-tile {
  position: absolute;
  width: 40px; height: 52px;
  background: linear-gradient(145deg, #f5f0e1, #e8e0cc);
  border: 2px solid #c0b89a;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
.mj-tile:hover { transform: translateY(-2px); box-shadow: 2px 4px 8px rgba(0,0,0,0.5); }
.mj-tile.selected { border-color: #e94560; box-shadow: 0 0 12px rgba(233,69,96,0.6); transform: translateY(-3px); }
.mj-tile.hint { border-color: #f0a500; box-shadow: 0 0 12px rgba(240,165,0,0.6); }
.mj-tile.blocked { opacity: 0.7; cursor: default; }
.mj-tile.blocked:hover { transform: none; box-shadow: 2px 2px 4px rgba(0,0,0,0.4); }

/* Layer offsets for 3D effect */
.mj-tile[data-layer="1"] { box-shadow: 3px 3px 6px rgba(0,0,0,0.5); }
.mj-tile[data-layer="2"] { box-shadow: 4px 4px 8px rgba(0,0,0,0.5); }
.mj-tile[data-layer="3"] { box-shadow: 5px 5px 10px rgba(0,0,0,0.5); }
.mj-tile[data-layer="4"] { box-shadow: 6px 6px 12px rgba(0,0,0,0.5); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: #1e1e3a; border-radius: 16px; padding: 2rem 2.5rem; text-align: center;
  animation: popIn 0.3s ease; border: 2px solid rgba(255,255,255,0.1); max-width: 90vw;
}
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.modal-content h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.3rem; }
.modal-content p { font-size: 0.95rem; color: rgba(255,255,255,0.7); margin-bottom: 0.3rem; }
.modal-stats { font-size: 1.1rem; font-weight: 700; color: #fff; }
.modal-content .btn { margin-top: 1rem; }

@media (max-width: 480px) {
  .topbar { padding: 0.4rem 0.6rem; }
  .game-title { font-size: 0.9rem; }
  .stats { font-size: 0.8rem; gap: 0.5rem; }
  .controls-bar { padding: 0.4rem 0.5rem; gap: 0.5rem; }
  .btn { padding: 0.3rem 0.7rem; font-size: 0.75rem; }
  .game-container { padding: 0.3rem; }
  .mj-tile { width: 32px; height: 42px; font-size: 1.1rem; }
}

@media (max-width: 360px) {
  .mj-tile { width: 26px; height: 36px; font-size: 0.9rem; border-radius: 4px; }
}

/* ===== SEO GAME INFO SECTION ===== */
.game-info {
  max-width: 780px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  line-height: 1.6;
}
.game-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-info h3 { font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.3rem; }
.game-info ul { padding-left: 1.2rem; }
.game-info li { margin-bottom: 0.2rem; }
