/* =========================================================
   MINIGAMES ARCADE & IN-GAME LEADERBOARD STYLES
   ========================================================= */

/* Dropdown color fix */
select, select.form-control {
  background: #242528 !important;
  color: #e8eaed !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  outline: none;
}

select option {
  background: #242528 !important;
  color: #e8eaed !important;
  padding: 8px;
}

body:not(.dark-theme) select, 
body:not(.dark-theme) select.form-control {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

body:not(.dark-theme) select option {
  background: #ffffff !important;
  color: #0f172a !important;
}

/* Enclosed card */
.section-enclosed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

body:not(.dark-theme) .section-enclosed-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Arcade tabs */
.games-arcade-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px 18px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

body:not(.dark-theme) .games-arcade-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.game-nav-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.game-nav-btn {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

body:not(.dark-theme) .game-nav-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.game-nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

body:not(.dark-theme) .game-nav-btn:hover {
  background: #e2e8f0;
}

.game-nav-btn.active {
  background: #28df99;
  color: #121318;
  border-color: #28df99;
  box-shadow: 0 0 12px rgba(40, 223, 153, 0.4);
}

body:not(.dark-theme) .game-nav-btn.active {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

.game-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.game-panel.active {
  display: block;
}

/* =========================================================
   1. TIC-TAC-TOE (RIGID FIXED CELLS)
   ========================================================= */
.ttt-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.ttt-status-bar {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.ttt-board-grid {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  grid-template-rows: repeat(3, 76px);
  gap: 8px;
  width: 244px;
  height: 244px;
  margin: 0 auto 16px;
  box-sizing: border-box;
}

.ttt-cell {
  width: 76px !important;
  height: 76px !important;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  cursor: pointer !important;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: background-color var(--transition-fast);
}

body:not(.dark-theme) .ttt-cell {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.ttt-cell:hover:not(.taken) {
  background: rgba(40, 223, 153, 0.15);
  border-color: #28df99;
}

/* =========================================================
   2. GAME 2048 (CHUẨN GABRIELE CIRULLI / MEMOBI ENGINE)
   ========================================================= */
.g2048-board-wrapper {
  position: relative;
  width: 290px;
  height: 290px;
  margin: 0 auto 14px;
  background: #18191c;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px;
  user-select: none;
  touch-action: none;
  box-sizing: border-box;
  overflow: hidden;
}

body:not(.dark-theme) .g2048-board-wrapper {
  background: #cbd5e1;
  border-color: #94a3b8;
}

.g2048-grid-bg {
  display: grid;
  grid-template-columns: repeat(4, 63px);
  grid-template-rows: repeat(4, 63px);
  gap: 7px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.g2048-grid-cell {
  width: 63px;
  height: 63px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  box-sizing: border-box;
}

body:not(.dark-theme) .g2048-grid-cell {
  background: rgba(255, 255, 255, 0.6);
}

.g2048-tile-container {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 278px;
  height: 278px;
  pointer-events: none;
}

.g2048-tile {
  position: absolute;
  width: 63px;
  height: 63px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  z-index: 10;
  box-sizing: border-box;
  transition: transform 180ms ease-in-out;
}

.g2048-tile .tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}

/* 16 Vị trí tọa độ chuẩn xác 100% */
.tile-position-1-1 { transform: translate(0px, 0px); }
.tile-position-1-2 { transform: translate(70px, 0px); }
.tile-position-1-3 { transform: translate(140px, 0px); }
.tile-position-1-4 { transform: translate(210px, 0px); }

.tile-position-2-1 { transform: translate(0px, 70px); }
.tile-position-2-2 { transform: translate(70px, 70px); }
.tile-position-2-3 { transform: translate(140px, 70px); }
.tile-position-2-4 { transform: translate(210px, 70px); }

.tile-position-3-1 { transform: translate(0px, 140px); }
.tile-position-3-2 { transform: translate(70px, 140px); }
.tile-position-3-3 { transform: translate(140px, 140px); }
.tile-position-3-4 { transform: translate(210px, 140px); }

.tile-position-4-1 { transform: translate(0px, 210px); }
.tile-position-4-2 { transform: translate(70px, 210px); }
.tile-position-4-3 { transform: translate(140px, 210px); }
.tile-position-4-4 { transform: translate(210px, 210px); }

/* Animation Tile Mới & Gộp */
.tile-new .tile-inner {
  animation: tileAppear 200ms ease forwards;
}

.tile-merged .tile-inner {
  animation: tileMergePop 220ms ease forwards;
}

@keyframes tileAppear {
  0% { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes tileMergePop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Màu sắc các số 2048 kinh điển */
.tile-2 .tile-inner { background: #eee4da; color: #776e65; }
.tile-4 .tile-inner { background: #ede0c8; color: #776e65; }
.tile-8 .tile-inner { background: #f2b179; color: #f9f6f2; }
.tile-16 .tile-inner { background: #f59563; color: #f9f6f2; }
.tile-32 .tile-inner { background: #f67c5f; color: #f9f6f2; }
.tile-64 .tile-inner { background: #f65e3b; color: #f9f6f2; }
.tile-128 .tile-inner { background: #edcf72; color: #f9f6f2; font-size: 1.05rem; box-shadow: 0 0 10px #edcf72; }
.tile-256 .tile-inner { background: #edcc61; color: #f9f6f2; font-size: 1.05rem; box-shadow: 0 0 10px #edcc61; }
.tile-512 .tile-inner { background: #edc850; color: #f9f6f2; font-size: 1rem; }
.tile-1024 .tile-inner { background: #edc53f; color: #f9f6f2; font-size: 0.85rem; }
.tile-2048 .tile-inner { background: #edc22e; color: #f9f6f2; font-size: 0.85rem; box-shadow: 0 0 16px #edc22e; }

.g2048-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 290px;
  margin: 0 auto 12px;
}

.g2048-score-box {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
}

body:not(.dark-theme) .g2048-score-box {
  background: #e2e8f0;
}

.g2048-dpad {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 4px;
  justify-content: center;
  margin: 10px auto;
}

.dpad-btn {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

body:not(.dark-theme) .dpad-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* =========================================================
   3. SUDOKU (SỐ 1-9 TRÊN 1 HÀNG + GHI CHÚ + XÓA)
   ========================================================= */
.sudoku-board-wrapper {
  position: relative;
  width: 290px;
  height: 290px;
  margin: 0 auto 12px;
}

.sudoku-start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  z-index: 50;
  animation: fadeIn 0.3s ease;
}

.sudoku-start-btn {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  background: #28df99;
  color: #121318;
  border: none;
  box-shadow: 0 0 20px rgba(40, 223, 153, 0.6);
  transition: all var(--transition-fast);
}

.sudoku-start-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px rgba(40, 223, 153, 0.8);
}

.sudoku-board-grid {
  display: grid;
  grid-template-columns: repeat(9, 32px);
  grid-template-rows: repeat(9, 32px);
  width: 290px;
  height: 290px;
  margin: 0 auto;
  border: 2px solid #28df99;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-sizing: border-box;
  transition: filter 0.3s ease;
}

.sudoku-board-grid.blurred {
  filter: blur(5px);
  pointer-events: none;
  opacity: 0.6;
}

.sudoku-cell {
  width: 32px !important;
  height: 32px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer !important;
  box-sizing: border-box;
  position: relative;
}

body:not(.dark-theme) .sudoku-cell {
  border-color: #cbd5e1;
}

.sudoku-cell:nth-child(3n) {
  border-right: 2px solid #28df99;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid #28df99;
}

.sudoku-cell.fixed {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.sudoku-cell.editable {
  background: rgba(0, 0, 0, 0.2);
  color: #00f2fe;
}

body:not(.dark-theme) .sudoku-cell.editable {
  background: #ffffff;
  color: #0284c7;
}

.sudoku-cell.selected {
  background: rgba(40, 223, 153, 0.3) !important;
  outline: 2px solid #28df99;
}

.sudoku-note-text {
  font-size: 0.6rem;
  color: #feca57;
  letter-spacing: 1px;
  line-height: 1;
}

/* Sudoku 1-9 Single Line Keypad */
.sudoku-numpad-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 12px auto 8px;
  max-width: 340px;
  flex-wrap: nowrap;
}

.sudoku-num-btn {
  flex: 1;
  height: 34px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

body:not(.dark-theme) .sudoku-num-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.sudoku-num-btn:hover {
  background: #28df99;
  color: #121318;
}

.sudoku-actions-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.sudoku-tool-btn {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

body:not(.dark-theme) .sudoku-tool-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

/* =========================================================
   IN-GAME LEADERBOARD TABLES
   ========================================================= */
.in-game-leaderboard-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  text-align: left;
}

body:not(.dark-theme) .in-game-leaderboard-box {
  border-top: 1px dashed #cbd5e1;
}

.in-game-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.78rem;
}

.in-game-table th {
  padding: 6px 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

body:not(.dark-theme) .in-game-table th {
  border-bottom: 1px solid #cbd5e1;
}

.in-game-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

body:not(.dark-theme) .in-game-table td {
  border-bottom: 1px solid #f1f5f9;
}
