/* Los colores (--page, --board, etc.) los define game.js según el estilo elegido. */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--page, #c7f0d8);
  color: var(--text, #43523d);
  font-family: var(--font, system-ui, sans-serif);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.screen { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- Menú ---------- */
#menu {
  justify-content: safe center;
  gap: 14px;
  overflow-y: auto;
  touch-action: pan-y;
}

.title {
  font-size: clamp(2.2rem, 11vw, 3.4rem);
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.record-line { text-align: center; color: var(--muted); }
.record-line strong { color: var(--text); }

.group h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.options { display: grid; gap: 8px; }
.options-2 { grid-template-columns: 1fr 1fr; }

.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  background: var(--board);
  border: 2px solid var(--border);
  border-radius: var(--ui-radius);
}
.opt.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }

.swatch {
  width: 22px; height: 22px; flex: none;
  border: 2px solid; border-radius: 4px;
  display: grid; place-items: center;
}
.swatch i { width: 8px; height: 8px; display: block; }

.hint { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 8px; }

.btn {
  min-height: 52px;
  padding: 10px 18px;
  border-radius: var(--ui-radius);
  border: 2px solid var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
}
.btn.primary { background: var(--accent); color: var(--accent-text); font-size: 1.25rem; }
.btn.ghost { background: transparent; border-color: var(--border); font-weight: 500; }
.btn:active, .opt:active, .icon-btn:active { transform: scale(0.97); }

/* ---------- Juego ---------- */
#game { gap: 10px; }

.hud { display: flex; align-items: center; gap: 18px; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.hud-btns { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  width: 48px; height: 48px;
  background: var(--board);
  border: 2px solid var(--border);
  border-radius: var(--ui-radius);
  font-size: 1.1rem;
  font-weight: 700;
}

.board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  display: block;
  background: var(--board);
  outline: 3px solid var(--border);
  border-radius: 2px;
}
body.walls #board { outline-color: var(--text); }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--page) 70%, transparent);
}
.card {
  width: min(86%, 300px);
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px;
  text-align: center;
  background: var(--board);
  border: 2px solid var(--border);
  border-radius: var(--ui-radius);
}
.card h2 { font-size: 1.5rem; }
.card p { color: var(--muted); white-space: pre-line; }

/* Flechas en pantalla: solo en dispositivos táctiles */
.dpad { display: none; }
body.touch .dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas: ". up ." "left down right";
  gap: 8px;
  width: min(100%, 300px);
  margin: 0 auto;
  flex: none;
}
.pad {
  height: clamp(54px, 9.5vh, 76px);
  background: var(--board);
  border: 2px solid var(--border);
  border-radius: var(--ui-radius);
  font-size: 1.5rem;
  color: var(--accent);
}
.pad.pressed { background: var(--accent); color: var(--accent-text); }
/* Celular acostado: el tablero a la izquierda y las flechas a la derecha */
@media (orientation: landscape) and (max-height: 520px) {
  #app { max-width: 900px; }
  body.touch #game {
    display: grid;
    grid-template-columns: 1fr 260px;
    grid-template-rows: auto 1fr;
    column-gap: 16px;
  }
  body.touch .hud { grid-column: 1 / -1; }
  body.touch .board-wrap { min-width: 0; }
  body.touch .dpad { align-self: center; width: 100%; }
}

.pad.up { grid-area: up; }
.pad.left { grid-area: left; }
.pad.right { grid-area: right; }
.pad.down { grid-area: down; }
