/* Block Cascade - Modern Falling Block Puzzle Stylesheet */

:root {
  --bg-primary: #0b0f19;
  --bg-surface: #151d30;
  --bg-surface-hover: #1e2942;
  --panel-border: #22304d;
  --board-bg: #070a12;
  --board-border: #2a3b5c;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-glow: rgba(56, 189, 248, 0.35);

  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --purple: #a855f7;

  --border: #22304d;
  --radius: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

/* --- Reset & Global Defaults --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* --- Header --- */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s ease;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
}

.back-link:hover, .back-link:focus-visible {
  color: var(--accent);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-icon {
  font-size: 1.5rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.icon-button {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-button:hover, .icon-button:focus-visible {
  background: var(--border);
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Game Container --- */
.game-container {
  flex: 1;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-header-text {
  text-align: center;
  margin-bottom: 1.5rem;
}

.game-title {
  font-size: 2rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 620px;
  margin: 0 auto;
}

/* --- Arcade Cabinet Layout --- */
.arcade-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
  max-width: 680px;
  margin-bottom: 1.5rem;
}

/* Side Panels */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 140px;
}

.panel-box {
  background-color: var(--bg-surface);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.85rem 0.65rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel-heading {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.hint-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Canvas Previews for Hold and Next */
#hold-canvas, #next-canvas {
  background-color: var(--board-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
}

/* Stats in side panels */
.stat-group {
  margin-bottom: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-group:last-child {
  margin-bottom: 0;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
}

.score-display {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: 1px;
}

.action-buttons-box {
  gap: 0.5rem;
}

.panel-action-btn {
  width: 100%;
  min-height: 44px;
}

/* --- Central Board Frame --- */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-frame {
  position: relative;
  background-color: var(--board-bg);
  border: 3px solid var(--board-border);
  border-radius: 10px;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
  overflow: hidden;
  line-height: 0;
}

#game-canvas {
  display: block;
  background-color: var(--board-bg);
  outline: none;
  touch-action: none;
}

/* Board Overlays (Start / Pause) */
.board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 20;
}

.overlay-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 240px;
}

.overlay-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}

.overlay-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.overlay-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.start-btn {
  width: 100%;
  min-height: 46px;
}

/* Mobile Stats Strip (Visible on small screens) */
.mobile-stats-strip {
  display: none;
  width: 100%;
  max-width: 300px;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.m-stat span {
  color: var(--text-muted);
}

.m-stat strong {
  color: var(--accent);
  font-family: var(--font-mono);
}

/* --- Mobile Touch Controls Bar --- */
.mobile-touch-controls {
  display: none;
  width: 100%;
  max-width: 380px;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
  user-select: none;
  -webkit-user-select: none;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.t-btn {
  flex: 1;
  min-height: 52px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.1s ease, transform 0.05s ease;
}

.t-btn:active {
  background-color: var(--border);
  transform: translateY(2px);
}

.t-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: -2px;
}

.t-drop {
  background-color: #1e2942;
  border-color: #38bdf8;
  color: #38bdf8;
}

.t-rotate {
  background-color: #1e2942;
}

/* --- Reusable Button Styles --- */
.btn-primary {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: var(--border);
}

/* --- Game Over Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-badge {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  margin-bottom: 1.25rem;
}

.modal-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.m-stat-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.m-stat-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

.high-score-banner {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.5rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-actions .btn-primary {
  width: 100%;
}

/* --- SEO Article & Content Styling --- */
.content-block {
  max-width: 800px;
  width: 100%;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-header {
  margin-bottom: 1.5rem;
}

.article-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.freshness-tag {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.article-section {
  margin-bottom: 2rem;
}

.article-section h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.85rem;
}

.article-section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 1.25rem 0 0.6rem;
}

.article-section p {
  color: #cbd5e1;
  margin-bottom: 1rem;
  line-height: 1.7;
}

.rules-list {
  padding-left: 1.25rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rules-list strong {
  color: #ffffff;
}

/* Strategy Cards */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.strategy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.strategy-card h4 {
  color: var(--accent);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.strategy-card p {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 0;
  line-height: 1.6;
}

/* FAQ Accordion */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-item[open] {
  border-color: var(--accent);
}

.faq-question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.faq-item[open] .faq-question::after {
  content: "−";
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: #cbd5e1;
  font-size: 0.925rem;
  line-height: 1.6;
}

/* Cross-links */
.cross-links {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.related-games-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.related-games-list li a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.related-games-list li a:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

/* --- Media Queries --- */
@media (max-width: 700px) {
  .game-title {
    font-size: 1.65rem;
  }

  .arcade-layout {
    gap: 0.75rem;
  }

  .side-panel {
    width: 90px;
  }

  .panel-box {
    padding: 0.5rem 0.35rem;
  }

  #hold-canvas, #next-canvas {
    width: 72px;
    height: 72px;
  }

  .desktop-stats, .desktop-score {
    display: none;
  }

  .mobile-stats-strip {
    display: flex;
  }

  .mobile-touch-controls {
    display: flex;
  }

  #game-canvas {
    width: 250px;
    height: 500px;
  }

  .hint-text {
    display: none;
  }
}

@media (max-width: 480px) {
  .arcade-layout {
    flex-wrap: wrap;
    justify-content: center;
  }

  .side-panel {
    flex-direction: row;
    width: 100%;
    max-width: 280px;
    justify-content: space-between;
  }

  .left-panel {
    order: 2;
  }

  .right-panel {
    order: 3;
  }

  .action-buttons-box {
    flex-direction: row;
  }

  #game-canvas {
    width: 240px;
    height: 480px;
  }
}
