:root {
  --bg: #050816;
  --bg2: #0a1330;

  --text: #f4f7ff;
  --muted: rgba(244,247,255,.65);

  --accent: #3ea6ff;
  --accent2: #7c5cff;

  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(62,166,255,.14), transparent 35%),
    radial-gradient(circle at bottom right, rgba(124,92,255,.10), transparent 35%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

/* =========================
   BODY — NOTCH FIX (SUBIDO 1mm)
========================= */
body {
  min-height: 100svh;
  display: flex;
  justify-content: center;

  padding-left: 12px;
  padding-right: 12px;
  padding-bottom: 12px;

  /* antes +48px — ahora SUBIDO un pelito */
  padding-top: calc(env(safe-area-inset-top, 0px) + 46px);
}

/* =========================
   APP LAYOUT
========================= */
.app-shell {
  width: min(100%, 640px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* =========================
   GAME (FOCUS)
========================= */
.canvas-wrap {
  position: relative;
  width: min(96vw, 560px);
  aspect-ratio: 1;

  /* ⭐ ESQUINAS RECTAS */
  border-radius: 0;
  overflow: visible;

  background: #060b18;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;

  /* ⭐ ESQUINAS RECTAS */
  border-radius: 0;
}

.canvas-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(62,166,255,.10), transparent 35%),
    linear-gradient(315deg, rgba(124,92,255,.10), transparent 35%);
}

/* =========================
   CONTROLS
========================= */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mid-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(320px, 90vw);
}

.up {
  width: min(320px, 90vw);
}

.dir-btn {
  border: none;
  min-height: 58px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}

.dir-btn:active {
  transform: scale(.97);
}

/* =========================
   ACTIONS
========================= */
.actions {
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-btn,
.secondary-btn {
  border: none;
  min-height: 54px;
  border-radius: 18px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.secondary-btn {
  background: rgba(255,255,255,.08);
}

/* =========================
   WORLD STATE (SIN POST)
========================= */
.world-state {
  width: min(420px, 95vw);
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}

.world-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.world-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .95rem;
}

/* ⭐ FIX: NO SALTOS DE LÍNEA */
.world-row {
  display: flex;
  justify-content: space-between;
  font-size: .95rem;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#world-user {
  color: var(--text);
  font-weight: 600;
}

#world-length {
  color: var(--accent);
  font-weight: 700;
}

/* =========================
   STATS
========================= */
.stats {
  width: min(420px, 95vw);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
  opacity: .85;
}

.stat-card {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.06);
}

.wide {
  grid-column: 1 / -1;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 4px;
}

.stat-card strong {
  font-size: 1.15rem;
}

/* =========================
   MOBILE TIGHT MODE
========================= */
@media (max-height: 850px) {
  .dir-btn {
    min-height: 54px;
  }

  .primary-btn,
  .secondary-btn {
    min-height: 50px;
  }

  .stat-card {
    padding: 10px;
  }
}
