/* ============================================================
   2048 — Game Stylesheet
   ============================================================ */

/* ----------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  --g-bg:            #10151d;
  --g-surface:       #181f2b;
  --g-surface-2:     #232d3d;
  --g-primary:       #f59e0b;
  --g-primary-hover: #d97706;
  --g-accent:        #f3722c;
  --g-text:          #f1f5f9;
  --g-text-muted:    #94a3b8;
  --g-border:        rgba(255, 255, 255, 0.08);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --board-bg:   #bbada0;
  --board-size: min(calc(100vw - 32px), 440px);
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  background-color: var(--g-bg);
  color: var(--g-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

ul { list-style: none; }
a  { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ----------------------------------------------------------
   Page
   ---------------------------------------------------------- */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

/* ----------------------------------------------------------
   Game area
   ---------------------------------------------------------- */
.game {
  width: 100%;
  max-width: calc(var(--board-size) + 32px);
  padding: var(--space-8) var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

/* Header: single row — title left, scores + button right, all centered */
.game__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.game__title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-right: auto;
  flex-shrink: 0;
}

.game__scores {
  display: flex;
  gap: var(--space-2);
}

/* Score boxes — Puzzli surface style */
.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--g-surface-2);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  min-width: 60px;
}

.score-box__label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--g-text-muted);
}

.score-box__value {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--g-text);
  line-height: 1.25;
}

/* New Game button */
.ctrl-btn {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--g-text-muted);
  background: var(--g-surface-2);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.ctrl-btn:hover { color: var(--g-text); background: var(--g-surface); }

/* ----------------------------------------------------------
   Board & Tiles (classic 2048 internal style — not changed)
   ---------------------------------------------------------- */
#grid {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  background: var(--board-bg);
  border-radius: 8px;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}

.cell-bg {
  position: absolute;
  left: 0; top: 0;
  border-radius: 6px;
  background: rgba(238, 228, 218, 0.35);
}

.tile-wrapper {
  position: absolute;
  left: 0; top: 0;
  z-index: 2;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  line-height: 1;
  font-size: 2rem;
  user-select: none;
}

.tile--2    { background: #eee4da; color: #776e65; }
.tile--4    { background: #ede0c8; color: #776e65; }
.tile--8    { background: #f2b179; color: #f9f6f2; }
.tile--16   { background: #f59563; color: #f9f6f2; }
.tile--32   { background: #f67c5f; color: #f9f6f2; }
.tile--64   { background: #f65e3b; color: #f9f6f2; }
.tile--128  { background: #edcf72; color: #f9f6f2; font-size: 1.5rem; }
.tile--256  { background: #edcc61; color: #f9f6f2; font-size: 1.5rem; }
.tile--512  { background: #edc850; color: #f9f6f2; font-size: 1.5rem; }
.tile--1024 { background: #edc53f; color: #f9f6f2; font-size: 1.125rem; }
.tile--2048 { background: #edc22e; color: #f9f6f2; font-size: 1.125rem; }
.tile--super { background: #3c3a32; color: #f9f6f2; font-size: 1rem; }

@keyframes tileAppear {
  0%   { transform: scale(0);    opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
@keyframes tileMerge {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.tile--new    { transform: scale(0); opacity: 0; }
.tile--appear { animation: tileAppear 200ms ease forwards; }
.tile--merge  { animation: tileMerge  150ms ease; }

/* ----------------------------------------------------------
   Result overlay
   ---------------------------------------------------------- */
.result-overlay[hidden] { display: none; }

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(16, 21, 29, 0.88);
  backdrop-filter: blur(6px);
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 320px;
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  gap: var(--space-4);
}

.result__emoji { font-size: 3rem; line-height: 1; }

.result__title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.result--win  .result__title { color: var(--g-primary); }
.result--lose .result__title { color: #ef4444; }

.result__message {
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  max-width: 260px;
  line-height: 1.5;
}

.result__scores {
  display: flex;
  gap: var(--space-8);
}

.result__score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.result__score-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--g-text-muted);
}

.result__score-value {
  font-size: 2rem;
  font-weight: 800;
}

.result__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.game-btn[hidden] { display: none; }

.game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-block: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 700;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}
.game-btn--primary {
  background-color: var(--g-primary);
  color: #1a0a00;
  font-weight: 800;
}
.game-btn--primary:hover {
  background-color: var(--g-primary-hover);
  transform: translateY(-2px);
}

/* ----------------------------------------------------------
   Info sections — same pattern as flagguess/hangman
   ---------------------------------------------------------- */
.info-section {
  width: 100%;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--g-border);
}

.info-section__inner {
  max-width: 480px;
  margin-inline: auto;
}

.info-section__title {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-5);
  text-align: center;
}

.info-section--support .info-section__inner {
  max-width: 640px;
}

.info-section--support .info-section__title {
  margin-bottom: var(--space-5);
}

.info-section__inner p {
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.7;
}

.info-section__inner p + p {
  margin-top: var(--space-4);
}

/* How to Play steps */
.htp-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  list-style: none;
}

.htp-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.htp-step__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  font-size: 0.875rem;
  font-weight: 800;
  color: #1a0a00;
  flex-shrink: 0;
}

.htp-step__text {
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.6;
  padding-top: 5px;
}

.support-copy {
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.7;
  text-align: center;
  max-width: 46ch;
  margin-inline: auto;
}

.support-copy + .support-copy,
.support-copy + .support-list {
  margin-top: var(--space-4);
}

.support-list {
  list-style: none;
  display: grid;
  gap: var(--space-3);
  max-width: 42ch;
  margin-inline: auto;
}

.support-list li {
  position: relative;
  padding-left: 1.25rem;
  color: var(--g-text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  text-align: left;
}

.support-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  opacity: 0.9;
}

/* FAQ accordion */
.faq {
  display: flex;
  flex-direction: column;
}

.faq__item { border-bottom: 1px solid var(--g-border); }
.faq__item:first-child { border-top: 1px solid var(--g-border); }

.faq__details { width: 100%; }

.faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--g-text);
  cursor: pointer;
  list-style: none;
  gap: var(--space-4);
  transition: color var(--transition-fast);
}
.faq__question::-webkit-details-marker { display: none; }

.faq__question::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}
.faq__details[open] .faq__question::after { transform: rotate(180deg); }
.faq__question:hover { color: var(--g-primary); }

.faq__answer {
  padding-bottom: var(--space-4);
  font-size: 0.9375rem;
  color: var(--g-text-muted);
  line-height: 1.6;
}

/* ----------------------------------------------------------
   Footer — same pattern as flagguess/hangman
   ---------------------------------------------------------- */
.menu__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-8);
  margin-top: auto;
}

.menu__footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.menu__footer-link {
  font-size: 0.8125rem;
  color: var(--g-text-muted);
  transition: color var(--transition-fast);
}
.menu__footer-link:hover { color: var(--g-text); }

.menu__footer-sep { color: var(--g-border); font-size: 0.8125rem; }

.menu__footer-brand {
  font-size: 0.8125rem;
  color: var(--g-text-muted);
  transition: color var(--transition-fast);
}
.menu__footer-brand:hover { color: var(--g-text); }

.menu__footer-brand strong {
  background: linear-gradient(135deg, var(--g-primary), var(--g-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */

/* Mobile (≤ 500px): header quebra em duas linhas */
@media (max-width: 500px) {
  .game__header {
    flex-wrap: wrap;
  }

  /* Linha 1: título (esquerda) + botão (direita) */
  .game__title {
    font-size: 1.75rem;
  }

  .ctrl-btn {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  /* Linha 2: score boxes ocupam a largura toda */
  .game__scores {
    order: 3;
    width: 100%;
    gap: var(--space-2);
  }

  .score-box {
    flex: 1;
    min-width: 0;
  }

  .tile             { font-size: 1.5rem; }
  .tile--128,
  .tile--256,
  .tile--512        { font-size: 1.25rem; }
  .tile--1024,
  .tile--2048       { font-size: 1rem; }
  .tile--super      { font-size: 0.875rem; }
}
