/* ==========================================================================
   Daily Calendar Puzzle — Modern Tactile Styling
   ========================================================================== */

:root {
  --cell-size: 52px;
  --cell-gap: 5px;
  --board-radius: 20px;
  --cell-radius: 8px;

  /* Theme Colors */
  --bg-gradient: radial-gradient(circle at 50% 15%, #f8fafc 0%, #e2e8f0 55%, #cbd5e1 100%);
  --text-main: #1e293b;
  --text-sub: #64748b;
  --text-muted: #94a3b8;

  /* Board Palette */
  --board-bg: #faf8f5;
  --board-border: #e7dfd5;
  --cell-bg: #efe9e0;
  --cell-border: #ded5c7;
  --cell-text: #475569;
  --cell-text-bold: #1e293b;
  --target-gold: #f59e0b;
  --target-gold-light: rgba(245, 158, 11, 0.15);

  /* Shadows */
  --shadow-board: 0 24px 48px -12px rgba(15, 23, 42, 0.22),
                  0 0 0 1px rgba(0, 0, 0, 0.05),
                  inset 0 2px 1px rgba(255, 255, 255, 0.9);
  --shadow-cell-inset: inset 0 2px 5px rgba(0, 0, 0, 0.12),
                       inset 0 1px 1px rgba(0, 0, 0, 0.15);
  --shadow-piece: 0 5px 12px -2px rgba(0, 0, 0, 0.22),
                  inset 0 1.5px 1px rgba(255, 255, 255, 0.45),
                  inset 0 -2px 3px rgba(0, 0, 0, 0.25);
  --shadow-piece-drag: 0 22px 38px -6px rgba(0, 0, 0, 0.38),
                       0 8px 16px -2px rgba(0, 0, 0, 0.2),
                       inset 0 1.5px 1px rgba(255, 255, 255, 0.6);

  /* UI Accents */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --accent: #f59e0b;

  --font-family: 'Fredoka', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

/* Base Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-family);
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Shell */
.app-container {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 20px;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  padding: 12px 20px;
  border-radius: 18px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06),
              0 0 0 1px rgba(255, 255, 255, 0.8);
}

.header-left {
  display: flex;
  align-items: center;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  animation: pulse-icon 4s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(4deg); }
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Date Selector Card */
.header-center {
  display: flex;
  justify-content: center;
  flex: 1;
}

.date-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.date-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.date-icon {
  font-size: 20px;
}

.date-info {
  display: flex;
  flex-direction: column;
}

.date-tag {
  font-size: 10px;
  font-weight: 700;
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.date-display {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}

.date-arrow {
  font-size: 12px;
  color: #94a3b8;
  transition: transform 0.2s;
}

.date-card:hover .date-arrow {
  color: var(--primary);
  transform: translateY(1px);
}

/* Header Right Buttons */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill-group {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.pill-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  color: #475569;
}

.icon-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

/* ==========================================================================
   Main Game Area
   ========================================================================== */
.game-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
  flex: 1;
}

/* Left Column: Board Section */
.stage-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Goal Banner */
.goal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  font-size: 13.5px;
  color: #334155;
  width: 100%;
  max-width: 440px;
  justify-content: center;
}

.goal-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.goal-text strong {
  color: #d97706;
  font-weight: 700;
}

/* ==========================================================================
   3D Board & Grid
   ========================================================================== */
.board-wrapper {
  position: relative;
  padding: 8px;
}

.board-frame {
  position: relative;
  background: var(--board-bg);
  border: 4px solid var(--board-border);
  border-radius: var(--board-radius);
  padding: 14px;
  box-shadow: var(--shadow-board);
  display: inline-block;
}

/* Grid: 7 rows x 7 cols */
.board-grid {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  grid-template-rows: repeat(7, var(--cell-size));
  gap: var(--cell-gap);
  position: relative;
}

/* Grid Cells */
.grid-cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--cell-bg);
  border-radius: var(--cell-radius);
  box-shadow: var(--shadow-cell-inset);
  border: 1px solid var(--cell-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--cell-text);
  letter-spacing: -0.01em;
  transition: all 0.2s;
  pointer-events: none;
}

/* Month Cell styling */
.grid-cell.cell-month {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Day Cell styling */
.grid-cell.cell-day {
  font-size: 14px;
  font-weight: 600;
}

/* Empty or Plateau placeholder cells */
.grid-cell.cell-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Target highlight (today's month / day) */
.grid-cell.cell-target {
  background: var(--target-gold-light);
  border: 2px dashed var(--target-gold);
  color: #b45309;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3), var(--shadow-cell-inset);
  animation: target-glow 2.5s ease-in-out infinite;
}

@keyframes target-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.25), var(--shadow-cell-inset);
  }
  50% {
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.5), var(--shadow-cell-inset);
  }
}

.grid-cell.cell-target::after {
  content: '★';
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 8px;
  color: #f59e0b;
}

/* Cell Hover Snap Highlight */
.grid-cell.snap-valid {
  background: rgba(16, 185, 129, 0.35) !important;
  border: 2px solid #10b981 !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4) !important;
}

.grid-cell.snap-invalid {
  background: rgba(239, 68, 68, 0.35) !important;
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important;
}

/* Solid Plateau (Embossed corner at row 6, cols 3-6) */
.board-plateau {
  position: absolute;
  left: calc(14px + 3 * (var(--cell-size) + var(--cell-gap)));
  top: calc(14px + 6 * (var(--cell-size) + var(--cell-gap)));
  width: calc(4 * var(--cell-size) + 3 * var(--cell-gap));
  height: var(--cell-size);
  background: linear-gradient(180deg, #f3ede2 0%, #e6ded0 100%);
  border: 1.5px solid #dcd1c0;
  border-radius: var(--cell-radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8),
              0 2px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.plateau-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}

.plateau-en {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #928373;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.plateau-zh {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #b0a394;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Also Row 0 & Row 1 Col 6 is outside border wall */
.grid-cell.cell-wall {
  background: linear-gradient(180deg, #f3ede2 0%, #e6ded0 100%);
  border: 1px solid #dcd1c0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

/* Placed Pieces Container inside Board */
.board-pieces-layer {
  position: absolute;
  top: 14px;
  left: 14px;
  width: calc(7 * var(--cell-size) + 6 * var(--cell-gap));
  height: calc(7 * var(--cell-size) + 6 * var(--cell-gap));
  pointer-events: none;
  z-index: 10;
}

/* ==========================================================================
   Stats Bar
   ========================================================================== */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  padding: 8px 24px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 440px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #475569;
}

.stat-icon {
  font-size: 15px;
}

.stat-label {
  font-weight: 500;
  color: #64748b;
}

.stat-val {
  font-weight: 700;
  color: #0f172a;
}

/* ==========================================================================
   Right Column: Piece Tray & Actions
   ========================================================================== */
.tray-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Action Control Bar */
.actions-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.35);
}

.btn-ghost {
  background: #ffffff;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

.btn-accent {
  background: #f59e0b;
  color: #ffffff;
}

/* Solution Navigator */
.solution-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.08);
  animation: slide-down 0.3s ease;
}

.nav-arrow {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #86efac;
  background: #ffffff;
  color: #166534;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.nav-arrow:hover {
  background: #dcfce7;
}

.nav-text {
  font-size: 13.5px;
  font-weight: 700;
  color: #166534;
}

/* Piece Tray Container */
.tray-container {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 16px;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.tray-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.tray-count {
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 8px;
  border-radius: 10px;
}

.tray-tips {
  font-size: 11.5px;
  color: #94a3b8;
  font-weight: 500;
}

/* Piece Grid in Tray */
.piece-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  min-height: 220px;
  align-items: center;
  justify-items: center;
  padding: 6px;
}

/* ==========================================================================
   Polyomino Piece Styling
   ========================================================================== */
.puzzle-piece {
  position: relative;
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
  transition: transform 0.15s cubic-bezier(0.2, 0, 0.1, 1),
              filter 0.15s ease;
}

.puzzle-piece:hover {
  filter: brightness(1.06);
}

.puzzle-piece.selected {
  outline: 3px solid #3b82f6;
  outline-offset: 4px;
  border-radius: 8px;
}

.puzzle-piece.dragging {
  cursor: grabbing !important;
  z-index: 1000 !important;
  opacity: 0.95;
  filter: brightness(1.1) drop-shadow(0 20px 30px rgba(0, 0, 0, 0.35));
}

.puzzle-piece.on-board {
  position: absolute;
  z-index: 20;
}

/* Tray Slot container */
.tray-slot {
  width: 100%;
  min-height: 120px;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 10px;
  position: relative;
  transition: all 0.2s;
}

.tray-slot:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.tray-slot.empty {
  opacity: 0.5;
  border-style: dotted;
}

/* Piece Unit Square */
.piece-block {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--piece-color);
  background-image: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 100%);
  border-radius: 5px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6),
              inset 0 -1.5px 2px rgba(0,0,0,0.3),
              0 2px 4px rgba(0,0,0,0.12);
}

/* Subtle grooved center indentation inside each block */
.piece-block::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

/* Tray preview piece scale */
.tray-slot .puzzle-piece {
  --cell-size: 26px;
  --cell-gap: 2px;
}

.tray-slot .puzzle-piece .piece-block {
  border-radius: 4px;
}

.tray-slot .puzzle-piece .piece-block::after {
  inset: 2px;
}

/* ==========================================================================
   Active Piece Floating Control Panel
   ========================================================================== */
.piece-controls {
  background: #ffffff;
  border-radius: 14px;
  padding: 10px 16px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slide-up 0.2s ease;
}

.piece-controls-label {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.piece-controls-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.ctrl-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.ctrl-btn-danger {
  color: #ef4444;
}

.ctrl-btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* Drag Layer */
.drag-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}

.modal-card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: scale-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid #f1f5f9;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #334155;
}

.modal-body {
  padding: 20px 22px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

/* Date Picker Grids */
.quick-date-row {
  display: flex;
  gap: 10px;
}

.picker-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.picker-grid {
  display: grid;
  gap: 6px;
}

.month-grid {
  grid-template-columns: repeat(6, 1fr);
}

.day-grid {
  grid-template-columns: repeat(7, 1fr);
}

.pick-item {
  height: 38px;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.pick-item:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.pick-item.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* Help Modal Content */
.help-content {
  gap: 14px;
}

.rule-block {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.rule-num {
  width: 26px;
  height: 26px;
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 800;
  font-size: 13px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.rule-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: #334155;
}

.rule-desc strong {
  display: block;
  margin-bottom: 2px;
  color: #0f172a;
  font-size: 14px;
}

.rule-desc ul {
  padding-left: 18px;
  margin-top: 6px;
}

.rule-desc li {
  margin-bottom: 4px;
}

kbd {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 0 #94a3b8;
}

/* Victory Celebration Modal */
.victory-card {
  text-align: center;
  position: relative;
  padding: 24px 24px 28px;
}

.victory-close {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 10;
  font-size: 26px;
  color: #94a3b8;
  cursor: pointer;
  background: transparent;
  border: none;
  line-height: 1;
}

.victory-close:hover {
  color: #1e293b;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.trophy-bounce {
  font-size: 56px;
  animation: bounce 1.2s cubic-bezier(0.28, 0.84, 0.42, 1) infinite alternate;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-12px); }
}

.victory-title {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 8px;
}

.victory-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-top: 4px;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
}

.vstat-box {
  display: flex;
  flex-direction: column;
}

.vstat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.vstat-lbl {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.victory-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 11000;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.25s ease forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-up {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================= */
@media (max-width: 960px) {
  :root {
    --cell-size: 46px;
    --cell-gap: 4px;
  }

  .game-main {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .tray-section {
    width: 100%;
    max-width: 480px;
  }

  .piece-tray {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 640px) {
  :root {
    --cell-size: 41px;
    --cell-gap: 3.5px;
  }

  .app-container {
    padding: 10px 12px 24px;
    gap: 14px;
  }

  .app-header {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }

  .header-left {
    order: 1;
  }

  .header-right {
    order: 2;
  }

  .header-center {
    order: 3;
    width: 100%;
  }

  .date-card {
    width: 100%;
    justify-content: center;
  }

  .board-frame {
    padding: 10px;
  }

  .piece-tray {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 380px) {
  :root {
    --cell-size: 36px;
    --cell-gap: 3px;
  }
}
