/* ---- TIPOGRAFÍA ----
   La fuente del juego es fonts/square-deal.ttf. Para cambiarla, reemplaza el archivo
   (o cambia la ruta de abajo) y ajusta el nombre en --font. Los glifos que la fuente
   no tenga (+, -, flechas) caen en Orbitron.
*/
@font-face {
  font-family: 'SquareDeal';
  src: url('fonts/square-deal.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
:root { --font: 'SquareDeal', 'Orbitron', 'Courier New', monospace; --ui: #ffffff; --bg: #000000; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #e9ebf0; color: #fff; font-family: var(--font); text-transform: uppercase; user-select: none; -webkit-user-select: none; }

/* ---- Marco tipo teléfono: #app se centra y mantiene la proporción; el JS (layoutApp) le da el tamaño.
   Todas las medidas de la UI usan cqw/cqh (relativas al marco), no a la ventana. ---- */
#app { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background: #000; container-type: size; }
#app.framed { border-radius: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.28), 0 0 0 6px #1a1a22; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 22px; padding: 24px; }
.screen.solid { background: #000; --ui: #fff; --bg: #000; }
.screen.dim { background: rgba(0,0,0,.75); --ui: #fff; --bg: #000; }
#menu, #hud, #maps { color: var(--ui); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; justify-content: center; gap: 18px; }

.big { font-size: clamp(40px, 10cqw, 96px); line-height: 1; }
.small { font-size: clamp(13px, 3cqw, 22px); opacity: .85; letter-spacing: .05em; line-height: 1.3; }
.tiny { display: block; font-size: .45em; opacity: .8; margin-top: 6px; }

.btn { font-family: var(--font); font-size: clamp(16px, 3.5cqw, 26px); padding: 14px 26px; border: 4px solid var(--ui); background: transparent; color: var(--ui); cursor: pointer; letter-spacing: .05em; line-height: 1; transition: transform .1s, background .15s, color .15s; }
.btn:hover { background: var(--ui); color: var(--bg); }
.btn:active { transform: scale(.95); }
.btn.big { font-size: clamp(22px, 5cqw, 36px); padding: 22px 34px; }
.btn.tiny-btn { font-size: clamp(12px, 2.5cqw, 16px); padding: 8px 14px; border-width: 3px; }

/* ---- Menú principal ---- */
#menu { justify-content: space-between; padding: 6cqh 24px; cursor: pointer; }
.title { font-size: clamp(34px, 9cqw, 110px); line-height: 1; letter-spacing: .02em; background-image: linear-gradient(90deg, #4fe3d3, #f4c2e8); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.tap { font-size: clamp(14px, 3cqw, 24px); letter-spacing: .1em; }
.blink { animation: blink 1.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.menu-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#speed { display: flex; align-items: center; gap: 10px; }
#speed-val { min-width: 3ch; text-align: center; }
.mini { font-family: var(--font); font-size: 1em; width: 2em; height: 2em; border: 3px solid var(--ui); background: transparent; color: var(--ui); cursor: pointer; line-height: 1; }
.mini:hover { background: var(--ui); color: var(--bg); }

/* ---- HUD ---- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#btn-pause { pointer-events: auto; position: absolute; top: 18px; left: 18px; width: 44px; height: 44px; background: transparent; border: 0; cursor: pointer; display: flex; gap: 8px; align-items: center; justify-content: center; }
#btn-pause span { display: block; width: 10px; height: 32px; background: var(--ui); }
#score-wrap { position: absolute; top: 14px; right: 22px; text-align: right; }
#score { font-size: clamp(28px, 6cqw, 56px); line-height: 1; display: inline-block; transform-origin: 80% 50%; }
#score.bump { animation: bump .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.55); } 100% { transform: scale(1); } }
.float { position: absolute; right: 4px; top: 100%; font-size: clamp(16px, 3cqw, 28px); animation: floatUp .7s ease-out forwards; }
@keyframes floatUp { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
#countdown { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(90px, 22cqw, 200px); line-height: 1; }
#countdown.pop { animation: pop .95s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(.9); opacity: .6; } }
#hint { position: absolute; left: 50%; bottom: 28cqh; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 14px 18px; background: var(--bg); border: 3px solid currentColor; }
#hint-key { font-size: clamp(40px, 9cqw, 80px); line-height: 1; width: 1.6em; height: 1.6em; display: flex; align-items: center; justify-content: center; border: 5px solid currentColor; animation: pulse .8s ease-in-out infinite alternate; }
#hint-text { font-size: clamp(13px, 3cqw, 22px); letter-spacing: .05em; max-width: 90cqw; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
#hud.shake { animation: shake .18s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---- Game over ---- */
.go-block { opacity: 0; transform: translateY(18px); transition: opacity .45s ease-out, transform .45s ease-out; }
.go-block.show { opacity: 1; transform: none; }
#go-new { margin-top: 8px; color: #ffe066; }

/* ---- Anuncio ---- */
#ad { background: #111; }
.ad-bar { width: min(70cqw, 420px); height: 14px; border: 3px solid #fff; }
#ad-fill { height: 100%; width: 0; background: #fff; transition: width 1s linear; }

/* ---- Mapas (tienda): nombre arriba, maqueta en medio, PLAY abajo ---- */
#maps { justify-content: flex-start; padding: 6cqh 24px 4cqh; }
#maps .lock { margin: auto 0; }
.maps-bottom { margin-top: auto; margin-bottom: 18px; }
#maps-back { position: absolute; top: 18px; left: 18px; }
.maps-top, .maps-bottom { perspective: 900px; }
.maps-top { margin-top: 44px; }
.map-name { font-size: clamp(38px, 11cqw, 120px); line-height: 1; text-shadow: 0 6px 0 rgba(0,0,0,.25); }
.maps-bottom { display: flex; align-items: center; justify-content: center; }
#maps-action { min-width: 200px; display: flex; justify-content: center; }
.play { font-family: var(--font); font-size: clamp(38px, 10cqw, 100px); line-height: 1; background: transparent; border: 0; color: var(--ui); opacity: .92; cursor: pointer; text-shadow: 0 6px 0 rgba(0,0,0,.25); transition: transform .1s; }
.play:hover { transform: scale(1.06); }
.play:active { transform: scale(.95); }
.nav { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--font); font-size: clamp(40px, 8cqw, 70px); line-height: 1; background: transparent; border: 0; color: var(--ui); opacity: .45; cursor: pointer; padding: 0 12px; }
.nav:hover { opacity: 1; }
.nav.left { left: 4px; }
.nav.right { right: 4px; }
.lock { color: var(--ui); opacity: .95; }
#maps-dots { display: flex; gap: 12px; }
#maps-dots span { width: 12px; height: 12px; background: var(--ui); opacity: .35; }
#maps-dots span.on { opacity: 1; }
/* Los textos giran sobre su eje vertical, en el sentido del deslizamiento */
.rot-out-l { animation: rotOutL .22s ease-in forwards; }
.rot-out-r { animation: rotOutR .22s ease-in forwards; }
.rot-in-r { animation: rotInR .28s ease-out; }
.rot-in-l { animation: rotInL .28s ease-out; }
@keyframes rotOutL { to { transform: rotateY(-90deg); opacity: 0; } }
@keyframes rotOutR { to { transform: rotateY(90deg); opacity: 0; } }
@keyframes rotInR { from { transform: rotateY(90deg); opacity: 0; } }
@keyframes rotInL { from { transform: rotateY(-90deg); opacity: 0; } }

/* ---- Cuenta y ranking ---- */
.input { font-family: var(--font); font-size: clamp(16px, 3.5cqw, 26px); text-transform: uppercase; padding: 10px 14px; width: 12ch; border: 4px solid var(--ui); background: transparent; color: var(--ui); outline: none; letter-spacing: .05em; }
.tiny-note { font-size: clamp(10px, 2.2cqw, 14px); opacity: .55; max-width: 80cqw; }
#acc-msg.err { color: #ff6b6b; }
#acc-msg.ok { color: #7dffb0; }
.rank-list { list-style: none; width: min(88cqw, 460px); max-height: 52cqh; overflow-y: auto; font-size: clamp(13px, 3cqw, 20px); text-align: left; border-top: 3px solid var(--ui); border-bottom: 3px solid var(--ui); }
.rank-list li { display: flex; gap: 12px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,.15); }
.rank-list li .n { width: 3.5ch; opacity: .6; text-align: right; }
.rank-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li.me { background: var(--ui); color: var(--bg); }
.rank-list li.me .n { opacity: 1; }

/* ---- Pantallas angostas (teléfono en vertical) ---- */
@container (max-width: 520px) {
  .screen { padding: 16px 10px; }
  .row { gap: 8px; }
  .btn { padding: 12px 8px; font-size: 12px; border-width: 3px; }
  .btn.big { padding: 16px 12px; font-size: 17px; }
  .tiny { font-size: .55em; margin-top: 4px; }
  #maps-action { min-width: 150px; }
}
