/* ==========================================================================
   TIUM_ | Word Hunt - Minimalist Black & White CSS Design System
   ========================================================================== */

:root {
  /* Color Palette - Monochrome & Premium */
  --bg-primary: #ffffff;
  --ink: #000000;
  --ink-soft: #333333;
  --ink-muted: #777777;
  --rule: #e5e5e5;
  
  /* Fonts */
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Outfit", system-ui, -apple-system, sans-serif;
  --font-mono: "Spline Sans Mono", monospace;
  
  /* Layout constraints */
  --board-max-width: 680px;
}

/* Resets & Base Configuration */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 24px;
}

/* Brand Header - Floated to top-left on desktop */
.brand-header {
  width: auto;
  z-index: 10;
}

.tium-logo {
  height: 60px;
  width: auto;
  display: block;
}

/* App Container - Borderless & Center-aligned */
.app-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Content wrapper that centers game components */
.content-centerer {
  width: 100%;
  max-width: var(--board-max-width);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Layout Flow */
.game-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: center;
}

.sidebar-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(34px, 5.5vw, 44px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  text-align: center;
}

.brand-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(14px, 2vw, 16px);
  color: var(--ink-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* Responsive Placement */
@media (min-width: 1024px) {
  .brand-header {
    position: absolute;
    top: 0;
    left: 0;
  }
  .app-container {
    padding-top: 0;
    max-width: 980px; /* Expanded for board + sidebar layout */
  }
  .content-centerer {
    max-width: 100%;
  }
  .game-body {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 48px;
  }
  .board-wrapper {
    flex: 1;
    max-width: var(--board-max-width);
    margin-bottom: 0;
  }
  .sidebar-wrapper {
    width: 280px;
    flex-shrink: 0;
  }
}
@media (max-width: 1023px) {
  .brand-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: center;
    width: 100%;
  }
}

/* Instructions Banner (Minimalist outline) */
.info-banner {
  border: 1px solid var(--ink);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.info-banner.hidden {
  display: none;
}

.info-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink-soft);
}

.info-icon {
  color: var(--ink);
  flex-shrink: 0;
  margin-top: 1px;
}

.info-content p b {
  font-weight: 600;
  color: var(--ink);
}

.close-banner-btn {
  background: none;
  border: none;
  font-size: 18px;
  font-weight: 300;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

/* Game Dashboard */
.game-dashboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  padding: 14px 0;
  margin-bottom: 28px;
  width: 100%;
}

.stats-group {
  display: flex;
  gap: 28px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.dashboard-controls {
  display: flex;
  gap: 6px;
}

/* Buttons Styling */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg-primary);
  border: 1px solid var(--ink);
}

.btn-primary:hover {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-tertiary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 4px 6px;
}

.btn-tertiary:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* Board Area (Border-free) */
.board-wrapper {
  position: relative;
  width: 100%;
  margin: 0 auto 32px;
  background: transparent;
  border: none;
  padding: 0;
}

/* Play Grid Container */
.grid-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
  touch-action: none;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  width: 100%;
  height: 100%;
}

/* Cell (Border-free) */
.cell {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(11px, 3.2vw, 22px);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: opacity 0.1s ease;
}

/* Cell hover */
@media (hover: hover) {
  .cell:hover {
    font-weight: 700;
  }
}

/* Active Drag & Solved font styles */
.cell.selected-temp {
  font-weight: 700;
}

.cell.selected-found {
  font-weight: 700;
}

/* Overlay Canvas */
.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

/* Capsule ovals styling (Pure Black) */
.drag-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4, 3; /* dashed outline for dragging */
  fill: none;
}

.found-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  fill: none;
}

/* Word Bank Styling */
.word-bank-section {
  width: 100%;
  margin-bottom: 32px;
}

.bank-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}

.bank-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ink);
}

.word-bank {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px 18px;
}

.bank-word {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.bank-word .word-bullet {
  width: 4px;
  height: 4px;
  background: var(--ink-muted);
  transform: rotate(45deg);
  display: inline-block;
}

/* Word bank found state */
.bank-word.found {
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-color: var(--ink-muted);
}

.bank-word.found .word-bullet {
  background: var(--ink);
  transform: rotate(45deg) scale(1.2);
}

/* Leaderboard Styling */
.leaderboard-section {
  width: 100%;
  margin-bottom: 32px;
}

.leaderboard-container {
  width: 100%;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.leaderboard-table th {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--ink);
  padding: 8px 6px;
}

.leaderboard-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table td.rank-cell {
  font-weight: 700;
  color: var(--ink);
}

.leaderboard-table td.time-cell {
  font-weight: 600;
  color: var(--ink);
}

/* App Footer */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  margin-top: 16px;
  width: 100%;
}

.branding-footer {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Looping Brand SVG Highlight */
.brand-highlight-path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  opacity: 0;
  transform-origin: center;
}

/* Animation triggers */
.animate-circle {
  animation: strokeDraw 1.8s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             strokeFadeOut 0.8s ease 3s forwards;
}

@keyframes strokeDraw {
  0% {
    stroke-dashoffset: 400;
    opacity: 0;
  }
  15% {
    opacity: 0.8;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0.8;
  }
}

@keyframes strokeFadeOut {
  0% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
  }
}

/* Success Overlay (Monochrome glassmorphism) */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.success-card {
  background: var(--bg-primary);
  border: 1px solid var(--ink);
  padding: 42px 36px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  position: relative;
}

.success-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  margin-bottom: 16px;
}

.success-card h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 8px;
}

.success-card p {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 16px;
}

.success-card p span {
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Leaderboard Submission styles */
.submit-score-container {
  margin: 16px 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.submit-label {
  font-size: 11px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

#player-name-input {
  border: none;
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 15px;
  text-align: center;
  padding: 6px 0;
  width: 100%;
  max-width: 180px;
  outline: none;
  margin-bottom: 12px;
}

#player-name-input::placeholder {
  color: var(--ink-muted);
  font-size: 12px;
}

.success-stats {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 16px 0;
  margin-bottom: 24px;
}

.success-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.4;
}

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

/* Solution Display Mode */
.cell.reveal-solution {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  font-weight: 700;
}

/* Responsive adjustments for ALL device formats */
@media (max-width: 680px) {
  body {
    padding: 24px 12px;
  }
  .word-bank {
    grid-template-columns: repeat(2, 1fr);
  }
  .btn {
    padding: 6px 8px;
  }
}

@media (max-width: 480px) {
  .game-dashboard {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
  }
  .stats-group {
    width: 100%;
    justify-content: space-around;
  }
  .dashboard-controls {
    width: 100%;
    justify-content: center;
  }
  .word-bank {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* Mobile landscape viewports scroll-safety */
@media (max-height: 600px) and (orientation: landscape) {
  body {
    padding: 16px;
  }
  .board-wrapper {
    max-width: 320px; /* shrink board in short landscape viewports */
  }
  .brand-header {
    position: static;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
  }
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
    padding: 0;
  }
  
  .app-container {
    padding: 20px !important;
    background: #ffffff !important;
  }
  
  .info-banner,
  .game-dashboard,
  .footer-actions,
  .success-overlay,
  .btn,
  .leaderboard-section {
    display: none !important;
  }
  
  .board-wrapper {
    margin-bottom: 24px !important;
  }
  
  .cell {
    color: #000000 !important;
  }

  .word-bank {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
  }
}
