/* Mahjong Solitaire Stylesheet */
.solitaire-main {
  max-width: 1200px;
  padding-block: 24px;
}

.solitaire-main h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  margin: 12px 0;
}

.solitaire-main em {
  color: #0d9488;
  font-style: normal;
}

/* Control and Stats Bar */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stats-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f1f5f9;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.stat-badge strong {
  color: #0f766e;
}

.control-btn {
  padding: 10px 16px;
  border: 1px solid #0f766e;
  border-radius: 10px;
  background: #0f766e;
  color: #ffffff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease-in-out;
}

.control-btn:hover:not(:disabled) {
  background: #115e59;
  border-color: #115e59;
  transform: translateY(-1px);
}

.control-btn.secondary {
  background: #ffffff;
  color: #0f766e;
  border-color: #cbd5e1;
}

.control-btn.secondary:hover:not(:disabled) {
  background: #f0fdfa;
  border-color: #0f766e;
}

.control-btn:disabled {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.solitaire-select {
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  font: inherit;
  font-size: 0.95rem;
  min-height: 44px;
  cursor: pointer;
  color: #1e293b;
}

/* Solitaire Table */
.board-container {
  position: relative;
  width: 100%;
  min-height: 600px;
  background: radial-gradient(circle at center, #065f46 0%, #064e3b 100%);
  border-radius: 24px;
  border: 8px solid #b45309;
  box-shadow: inset 0 4px 16px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.15);
  overflow: auto;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.board-viewport {
  position: relative;
  width: 960px;
  height: 560px;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

/* Individual 3D Mahjong Tile */
.sol-tile {
  position: absolute;
  width: 52px;
  height: 68px;
  background: #fffbeb;
  border-radius: 6px;
  border: 2px solid #a8a29e;
  box-sizing: border-box;
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

/* 3D Layer Elevation */
.sol-tile[data-z="0"] {
  box-shadow: -2px 2px 0 #78716c, -3px 3px 6px rgba(0,0,0,0.3);
}
.sol-tile[data-z="1"] {
  box-shadow: -3px 3px 0 #78716c, -5px 5px 8px rgba(0,0,0,0.35);
}
.sol-tile[data-z="2"] {
  box-shadow: -4px 4px 0 #78716c, -7px 7px 10px rgba(0,0,0,0.4);
}
.sol-tile[data-z="3"] {
  box-shadow: -5px 5px 0 #78716c, -9px 9px 12px rgba(0,0,0,0.45);
}
.sol-tile[data-z="4"] {
  box-shadow: -6px 6px 0 #78716c, -11px 11px 14px rgba(0,0,0,0.5);
}

/* Tile Faces & Typography */
.sol-tile .symbol {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.sol-tile .label {
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Color schemes for suits */
.sol-tile[data-cat="characters"] .symbol { color: #dc2626; }
.sol-tile[data-cat="characters"] .label { color: #991b1b; }

.sol-tile[data-cat="bamboo"] .symbol { color: #15803d; }
.sol-tile[data-cat="bamboo"] .label { color: #166534; }

.sol-tile[data-cat="dots"] .symbol { color: #2563eb; }
.sol-tile[data-cat="dots"] .label { color: #1e40af; }

.sol-tile[data-cat="winds"] .symbol { color: #475569; }
.sol-tile[data-cat="winds"] .label { color: #334155; }

.sol-tile[data-cat="dragons"] .symbol { color: #b91c1c; }
.sol-tile[data-cat="dragons"] .label { color: #7f1d1d; }

.sol-tile[data-cat="seasons"] { background: #fefce8; }
.sol-tile[data-cat="seasons"] .symbol { color: #d97706; }
.sol-tile[data-cat="seasons"] .label { color: #b45309; }

.sol-tile[data-cat="flowers"] { background: #fdf2f8; }
.sol-tile[data-cat="flowers"] .symbol { color: #db2777; }
.sol-tile[data-cat="flowers"] .label { color: #be185d; }

/* Interactive States */
.sol-tile.free:hover {
  border-color: #0d9488;
  transform: translate(calc(var(--base-x) - 2px), calc(var(--base-y) - 3px));
  z-index: 1000 !important;
}

.sol-tile.selected {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
  border-width: 3px;
  transform: translate(calc(var(--base-x) - 3px), calc(var(--base-y) - 5px));
  box-shadow: -4px 6px 12px rgba(245, 158, 11, 0.5) !important;
  z-index: 1001 !important;
}

.sol-tile.hinted {
  outline: 3px solid #10b981;
  animation: hintPulse 1s infinite alternate;
  z-index: 999 !important;
}

@keyframes hintPulse {
  0% {
    box-shadow: 0 0 4px #10b981, -3px 3px 6px rgba(0,0,0,0.3);
  }
  100% {
    box-shadow: 0 0 16px #34d399, -5px 5px 12px rgba(16, 185, 129, 0.7);
  }
}

/* Blocked / Unavailable Tiles */
.sol-tile.blocked {
  opacity: 0.82;
  filter: brightness(0.92);
  cursor: not-allowed;
}

.sol-tile:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

/* Modals & Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  border-radius: 16px;
  backdrop-filter: blur(4px);
  padding: 20px;
}
/* The author rule above sets display:flex, which would override the UA [hidden] rule and leave the pause, win and
   no-moves overlays covering (and blocking) the board even while hidden. */
.overlay[hidden] {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-card h2 {
  font-size: 1.8rem;
  margin-top: 0;
  margin-bottom: 12px;
  color: #0f172a;
}

.modal-card p {
  color: #475569;
  margin-bottom: 24px;
}

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

/* Panel Instructions */
.panel {
  padding: 22px;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  margin: 20px 0;
  background: #fff;
  color: #182235;
}

.panel summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .board-container {
    padding: 16px;
    min-height: 480px;
  }
}

@media (max-width: 768px) {
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .control-group, .stats-group {
    justify-content: center;
  }
  .board-container {
    padding: 10px;
    min-height: 400px;
  }
}
