/* ==========================================================================
   TURRUS - Re-Architected Layout & Design System
   Punctula Glass Header Buttons + High Contrast Menu Buttons + Circular Rules Icon
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #0b0f17;       /* Deep Charcoal / Off-black */
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(212, 175, 55, 0.3); /* Subtle 1px Pale Gold border */

  /* Accent Colors */
  --gold-primary: #d4af37;    /* Pale Gold */
  --gold-glow: rgba(212, 175, 55, 0.4);
  --gold-gradient: linear-gradient(135deg, #e5c158 0%, #b8860b 100%);
  --silver-gradient: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%);

  /* Text & Fonts */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Geometry & Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-pill: 9999px;

  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* App Container (Fixed 100vh Mobile Viewport) */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 16px 16px 16px;
  position: relative;
  overflow: hidden;
}

/* Top Header Navbar Bar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  backdrop-filter: blur(12px);
}

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

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

.brand-title {
  font-family: var(--font-serif); /* 'Playfair Display' which has true lowercase glyphs */
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: none !important; /* Forces lowercase 'urrus' */
  font-variant: normal !important;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Punctula Style Header Action Icon Buttons */
.btn-icon {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-icon:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--gold-primary);
  transform: scale(1.05);
  box-shadow: 0 0 12px var(--gold-glow);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Screen Views Container */
.screen-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow-y: auto;
}

.screen-view {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.3s ease forwards;
}

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

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

/* Option Cards & Pill Groups */
.card-option {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

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

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-normal);
}

.pill-btn.active {
  background: var(--gold-primary);
  color: #0b0f17;
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Circular Rules Info Button (ℹ️) */
.btn-info-pop {
  width: 30px;
  height: 30px;
  border-radius: 50% !important; /* Perfect circle */
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--gold-primary);
  color: var(--gold-primary);
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-info-pop:hover {
  background: var(--gold-primary);
  color: #0b0f17;
  transform: scale(1.15);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Main Navigation & Action Buttons with High Contrast Grey Background */
.menu-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-menu {
  width: 100%;
  padding: 15px 18px;
  background: rgba(30, 41, 59, 0.7); /* High contrast grey-slate background */
  border: 1.5px solid var(--gold-primary); /* High contrast visible gold border */
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition-normal);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-menu:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-primary);
  box-shadow: 0 0 18px var(--gold-glow);
  transform: translateY(-2px);
}

.btn-menu.primary {
  background: var(--gold-gradient);
  border: none;
  color: #0b0f17;
  font-weight: 700;
  box-shadow: 0 0 20px var(--gold-glow);
}

.btn-menu.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 28px var(--gold-glow);
}

/* Game Area Header & Stats */
.game-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

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

.stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

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

/* Interactive SVG Board */
.board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  min-height: 280px;
}

#hanoiSvg {
  width: 100%;
  height: 100%;
  max-height: 360px;
}

.svg-base {
  fill: #1e293b;
  stroke: var(--border-glass);
  stroke-width: 1.5;
}

.svg-peg {
  fill: #334155;
  cursor: pointer;
  transition: fill 0.2s ease;
}

.svg-peg:hover {
  fill: var(--gold-primary);
}

.svg-disk {
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.svg-disk:hover {
  filter: drop-shadow(0 0 12px var(--gold-glow));
}

.svg-disk.selected {
  stroke: #ffffff;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 16px var(--gold-primary));
  transform: translateY(-8px);
}

/* Modals System */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(12px);
  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: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 14px;
  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.25rem;
  color: var(--gold-primary);
}

/* 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); }
}

/* 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;
}

