/* style.css — Tetris Comunitel. Mobile first, paleta ink/flame del sitio. */

:root {
  --ink-950: #0A0A0B;
  --ink-900: #121212;
  --ink-800: #1A1B1C;
  --ink-700: #212222;
  --flame-300: #FFB347;
  --flame-400: #FF7A1A;
  --flame-500: #FF4B00;
  --flame-600: #FF2A00;
  --flame-grad: linear-gradient(135deg, #FF2A00 0%, #FF7A1A 60%, #FFB347 100%);
  --white: #fff;
  --mute: #9A9A9D;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-sans: Roboto, system-ui, sans-serif;
  --radius: 14px;
  --panel-w: 66px;
  --gap: 8px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink-950);
  color: var(--white);
  font-family: var(--font-sans);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% -5%, rgba(255,75,0,0.22), transparent 70%),
    radial-gradient(40% 30% at 90% 100%, rgba(255,122,26,0.08), transparent 70%);
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px calc(8px + var(--safe-b));
  gap: var(--gap);
}
.app.flash::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: rgba(255,122,26,0.12);
  animation: stageFlash 380ms ease-out forwards;
}
@keyframes stageFlash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- cabecera ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  height: 40px; flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--white); }
.brand__mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--flame-grad);
  box-shadow: 0 6px 18px -6px rgba(255,42,0,0.8);
}
.brand__name { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.top__title {
  font-family: var(--font-display); font-weight: 500; font-size: 12px;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--flame-300);
  margin-left: auto;
}
.top__actions { display: flex; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); color: var(--white); font-size: 14px; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.1); }
.icon-btn--exit { color: rgba(255,255,255,0.7); font-size: 16px; }
.icon-btn--exit:hover { color: var(--flame-300); border-color: rgba(255,122,26,0.45); }
.link-back {
  display: block; margin-top: 6px; font-size: 12px; color: var(--mute); text-decoration: none;
  font-family: var(--font-display); font-weight: 500; letter-spacing: 0.02em;
}
.link-back:hover { color: var(--white); }

/* ---------- escenario ---------- */
/* Móvil: franja superior con hold · stats · siguiente, y el tablero a todo el ancho. */
.stage {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "left right" "board board";
  gap: var(--gap);
}
.panel { display: flex; min-width: 0; gap: 6px; }
.panel--left { grid-area: left; flex-direction: row; }
.panel--right { grid-area: right; }
.panel__block {
  background: var(--ink-900); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 7px 6px; display: flex; flex-direction: column; gap: 4px;
}
.panel--left .panel__block { width: 48px; flex: none; }
.panel--right .panel__block { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.panel--right .panel__label { width: 100%; }
.panel__label {
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--mute); font-weight: 500; white-space: nowrap;
}
.preview { display: block; }
.preview--hold { width: 100%; height: 34px; }
.preview--next { width: 30px; height: 34px; }
.preview--small { width: 24px; opacity: 0.7; }
.stats { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.stat {
  min-width: 0;
  background: var(--ink-900); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px; padding: 3px 7px; display: flex; flex-direction: column; justify-content: center; gap: 0;
}
.stat .panel__label { font-size: 8px; letter-spacing: 0.14em; }
.stat__value {
  font-family: var(--font-display); font-weight: 700; font-size: 12px; line-height: 1.2;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat--best .stat__value { color: var(--flame-300); }
.pop { animation: pop 320ms cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); color: var(--flame-300); } 100% { transform: scale(1); } }

.board-wrap { grid-area: board; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
.board-frame {
  position: relative;
  border-radius: 10px;
  border: 1px solid rgba(255,122,26,0.35);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03), 0 30px 80px -30px rgba(255,42,0,0.45), 0 0 40px -20px rgba(255,122,26,0.5);
  overflow: hidden;
  background: #101012;
}
#board { display: block; touch-action: none; cursor: pointer; }

/* ---------- toast de marketing ---------- */
.toast {
  position: absolute; left: 50%; top: 14%;
  transform: translate(-50%, -8px) scale(0.9);
  opacity: 0; pointer-events: none;
  padding: 8px 14px; border-radius: 999px;
  background: var(--flame-grad); color: var(--white);
  font-family: var(--font-display); font-weight: 600; font-size: 13px; white-space: normal; text-align: center;
  width: max-content; max-width: 88%; line-height: 1.25; letter-spacing: 0.01em;
  box-shadow: 0 12px 30px -10px rgba(255,42,0,0.8), 0 0 0 1px rgba(255,179,71,0.4) inset;
  transition: transform 260ms cubic-bezier(.2,1.2,.4,1), opacity 220ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast--big { font-size: 15px; padding: 10px 18px; background: var(--white); color: var(--flame-600); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,11,0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 12px; animation: fadeIn 220ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay__card { text-align: center; width: 100%; max-width: 300px; animation: rise 320ms cubic-bezier(.2,1.2,.4,1); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.eyebrow {
  font-family: var(--font-display); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--flame-300); margin-bottom: 6px;
}
.overlay__title {
  font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; margin: 0 0 10px;
  letter-spacing: -0.03em;
  background: var(--flame-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay__title--sm { font-size: 30px; }
.overlay__text { font-size: 13px; line-height: 1.5; color: rgba(255,255,255,0.75); margin: 0 0 14px; }
.grad { background: var(--flame-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 500; }
.hint { font-size: 10.5px; color: var(--mute); margin: 12px 0 0; line-height: 1.5; }
.hint--keys { display: none; }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px; margin-bottom: 8px;
  background: var(--white); color: var(--flame-600);
  font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.final { margin: 4px 0 12px; }
.final__main { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.final__score { font-family: var(--font-display); font-weight: 700; font-size: 42px; line-height: 1; letter-spacing: -0.03em; }
.final__row { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }
.final__row > div { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--font-display); font-weight: 600; font-size: 15px; }

.overlay__actions { display: flex; flex-direction: column; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 18px; border-radius: 999px; border: 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; text-decoration: none; color: var(--white);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}
.btn:active { transform: scale(0.97); }
.btn--flame {
  background: var(--flame-grad);
  box-shadow: 0 10px 40px -10px rgba(255,42,0,0.6), 0 0 0 1px rgba(255,122,26,0.25) inset;
}
.btn--flame:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn--ghost { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14); }
.btn--ghost:hover { background: rgba(255,255,255,0.09); }
.btn--wa { background: #1fbf5c; box-shadow: 0 10px 30px -12px rgba(31,191,92,0.8); }

/* ---------- controles táctiles ---------- */
.controls {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.25fr 1fr 1fr;
  gap: 8px;
}
.ctl {
  height: 58px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
  background: var(--ink-800); color: var(--white); font-size: 22px; cursor: pointer;
  touch-action: none; transition: transform 80ms ease, background 80ms ease;
}
.ctl__txt { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; }
.ctl--rotate { background: var(--flame-grad); font-size: 28px; box-shadow: 0 10px 30px -12px rgba(255,42,0,0.7); }
.ctl--hard { color: var(--flame-300); }
.ctl.is-pressed { transform: scale(0.94); background: var(--ink-700); }
.ctl--rotate.is-pressed { filter: brightness(1.15); background: var(--flame-grad); }

/* ---------- pantallas medianas / escritorio ---------- */
@media (min-width: 560px) {
  :root { --panel-w: 96px; --gap: 12px; }
  .stage {
    grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--panel-w);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "left board right";
  }
  .panel { flex-direction: column; gap: 10px; }
  .panel--left .panel__block { width: auto; }
  .panel--right .panel__block { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .stats { flex: none; display: flex; flex-direction: column; gap: 6px; }
  .stat { flex: none; gap: 3px; padding: 7px 6px; border-radius: 12px; }
  .stat .panel__label { font-size: 10px; letter-spacing: 0.2em; }
  .panel__label { font-size: 10px; }
  .stat__value { font-size: 18px; }
  .preview--hold, .preview--next { width: 100%; height: 60px; }
  .preview--small { height: 44px; }
  .toast { font-size: 15px; padding: 10px 18px; }
}
@media (min-width: 900px) {
  :root { --panel-w: 150px; --gap: 18px; }
  .app { padding: 16px 20px; }
  .top { height: 48px; }
  .top__title { font-size: 13px; }
  .stage { grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--panel-w); width: 100%; max-width: 820px; margin: 0 auto; }
  .panel__block, .stat { padding: 12px; border-radius: 14px; }
  .stat__value { font-size: 24px; }
  .preview--hold, .preview--next { height: 78px; }
  .preview--small { height: 56px; }
  .overlay__card { max-width: 340px; }
  .overlay__title { font-size: 56px; }
  .overlay__text { font-size: 14px; }
}
/* En escritorio con mouse escondemos los botones táctiles y mostramos el hint de teclado */
@media (hover: hover) and (pointer: fine) {
  .controls { display: none; }
  .hint--touch { display: none; }
  .hint--keys { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .btn, .ctl, .overlay, .overlay__card { transition: none; animation: none; }
}
