* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #0b0b0b;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
#wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
#game {
  display: block;
  background: #000;
  box-shadow: 0 0 0 2px #1a1a1a, 0 0 40px rgba(205, 214, 0, .15);
}

#touch { display: none; }
body.touch #touch { display: block; }
#touch .pad {
  position: fixed; bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 14px; z-index: 5;
}
#touch .pad.left { left: max(14px, env(safe-area-inset-left)); }
#touch .pad.right { right: max(14px, env(safe-area-inset-right)); }
#touch button {
  width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid #CDD600;
  background: rgba(17, 17, 17, .55);
  color: #CDD600;
  font: 24px/1 sans-serif;
  touch-action: none;
}
#touch button.active { background: rgba(205, 214, 0, .5); color: #111; }
#touch button.jump { width: 78px; height: 78px; }
#touch button.pause {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 40px; height: 40px; font: 14px/1 'Press Start 2P', monospace; z-index: 5;
}

#rotate {
  display: none;
  position: fixed; inset: 0; z-index: 10;
  align-items: center; justify-content: center;
  background: #111; color: #CDD600;
  font: 16px/1.6 'Press Start 2P', monospace; text-align: center; padding: 20px;
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
}

#fsBtn {
  display: none;
  position: fixed; z-index: 6;
  top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid #CDD600; background: rgba(17, 17, 17, .55); color: #CDD600;
  font: 20px/1 sans-serif; cursor: pointer;
  touch-action: none;
}
body.fs-ok #fsBtn { display: block; }
body.touch #fsBtn { right: calc(max(10px, env(safe-area-inset-right)) + 50px); }

#iosHint {
  display: none;
  position: fixed; z-index: 7; left: 50%; transform: translateX(-50%);
  top: max(8px, env(safe-area-inset-top));
  max-width: min(92vw, 560px);
  align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px; border-radius: 10px;
  background: rgba(17, 17, 17, .92); border: 2px solid #CDD600; color: #fff;
  font: 13px/1.35 -apple-system, system-ui, sans-serif;
}
#iosHint b { color: #CDD600; }
#iosHint button {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: #CDD600; color: #111; font: 14px/1 sans-serif;
}
body.ios-hint #iosHint { display: flex; }

/* Tarjeta de los 3 primeros en terminar; se superpone al canvas */
#wrap { position: relative; }
#winner {
  display: none;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  align-items: center; justify-content: center;
  pointer-events: none; z-index: 4;
}
body.winner #winner { display: flex; }
#winner .card {
  width: 74%; padding: 2.6% 3%;
  background: rgba(11, 11, 20, .92);
  border: 3px solid #CDD600; border-radius: 10px;
  box-shadow: 0 0 30px rgba(205, 214, 0, .35);
  color: #fff; text-align: center;
  font: clamp(10px, 2.4vmin, 20px)/1.45 -apple-system, system-ui, sans-serif;
}
#winner .title {
  font: clamp(12px, 3.6vmin, 30px)/1.3 'Press Start 2P', monospace;
  color: #CDD600; margin-bottom: .6em;
}
#winner .msg { font-size: 1.25em; font-weight: 700; }
#winner .place {
  display: inline-block; color: #111; background: #CDD600;
  padding: 0 .35em; border-radius: 6px; font-size: 1.3em;
}
#winner .cta { margin-top: .7em; }
#winner .cta b { color: #CDD600; }
#winner .meta { margin-top: .8em; color: #aaa; font-size: .85em; }
#winner .code { color: #fff; font-weight: 700; letter-spacing: .15em; font-family: ui-monospace, Menlo, monospace; }
