/*
 * QUINDECIM - Premium Dark Slate Design System
 * 100% Serverless PWA Sliding Puzzle App
 */

:root {
  --bg-dark: #0b0f17;
  --bg-card: rgba(17, 24, 39, 0.85);
  --border-glass: rgba(255, 255, 255, 0.12);
  --gold-primary: #d4af37;
  --gold-light: #fef08a;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 9999px;
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 500px;
  height: 100%;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  position: relative;
  overflow: hidden;
}

/* App Header Bar */
.app-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(12px);
  z-index: 10;
}

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

.brand-icon-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: none !important;
  font-variant: normal !important;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--gold-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:active {
  transform: scale(0.92);
  background: rgba(212, 175, 55, 0.2);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* Screen Navigation & Containers */
.screen-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}

.screen-view {
  display: none;
  flex-direction: column;
  padding: 16px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

.screen-view.active {
  display: flex;
}

/* Card Option Containers */
.card-option {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Pill Selectors */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  flex: 1;
  min-width: 65px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-primary);
  color: var(--gold-light);
  box-shadow: 0 0 10px var(--gold-glow);
}

/* Action Menu Buttons */
.menu-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-menu {
  width: 100%;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-menu.primary {
  background: linear-gradient(135deg, #d4af37 0%, #854d0e 100%);
  border-color: #fef08a;
  color: #0b0f17;
  box-shadow: 0 4px 16px var(--gold-glow);
}

.btn-menu:active {
  transform: scale(0.98);
}

/* Game Stats Top Bar */
.game-stats-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold-primary);
}

/* Sliding Puzzle Board Area */
.board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.puzzle-board {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  display: grid;
  gap: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 8px 24px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Sliding Puzzle Tiles */
.puzzle-tile {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gold-light);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease-out, box-shadow 0.15s ease;
  background-size: cover;
  background-position: center;
}

.puzzle-tile:active {
  transform: scale(0.95);
  box-shadow: 0 0 12px var(--gold-glow);
}

.puzzle-tile.blank {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

.puzzle-tile.movable {
  border-color: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--gold-primary);
}

.btn-info-pop {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Toggle Switch Control for Settings */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
  border: 1px solid var(--border-glass);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: #0b0f17;
}

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

.toast {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--gold-primary);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 0 16px var(--gold-glow);
  animation: toastIn 0.3s ease forwards;
}

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