@font-face {
  font-family: 'Press Start 2P';
  src: url('/fonts/press-start-2p.woff2') format('woff2');
  font-display: swap;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #05070f; overflow: hidden; touch-action: none; }
body { font-family: 'Press Start 2P', monospace; color: #fff; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.hud-btn {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  width: 44px; height: 44px; border: 3px solid #fff; border-radius: 8px; background: rgba(0,0,0,.45);
  color: #fff; font-size: 12px; z-index: 5; display: flex; gap: 6px; align-items: center; justify-content: center; padding: 0;
}
.hud-btn span { width: 5px; height: 16px; background: #fff; display: block; }

/* Touch controls */
#touch { position: absolute; inset: auto 0 0 0; height: 40%; pointer-events: none; z-index: 4; }
#touch .pad-left { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 14px; pointer-events: auto; }
#touch .pad-right { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: auto; }
.tbtn {
  width: 74px; height: 74px; border-radius: 50%; border: 3px solid rgba(255,255,255,.75);
  background: rgba(255,255,255,.14); color: #fff; font-size: 22px; touch-action: none;
}
.tbtn.big { width: 96px; height: 96px; font-size: 13px; background: rgba(214,43,43,.45); }
.tbtn.on { background: rgba(255,255,255,.4); transform: scale(.94); }

/* Dialogue */
#dialog {
  position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(92vw, 820px); min-height: 110px; padding: 16px 18px 30px; z-index: 6;
  background: rgba(8,12,32,.92); border: 4px solid #fff; border-radius: 10px; box-shadow: 0 0 0 4px #d62b2b;
}
#dlgWho { color: #ffd75e; font-size: 12px; margin-bottom: 10px; min-height: 12px; }
#dlgText { font-size: clamp(11px, 1.8vw, 15px); line-height: 1.7; }
#dlgHint { position: absolute; right: 14px; bottom: 8px; font-size: 9px; color: #9ad8ff; animation: blink 1s steps(2) infinite; }
#dlgSkip { position: absolute; left: 12px; bottom: 6px; font-size: 9px; background: none; border: 0; color: #aab; padding: 4px; }
@keyframes blink { 50% { opacity: 0; } }

/* Screens (menus) */
#screen {
  position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  overflow-y: auto; touch-action: pan-y;
}
#screen.dim { background: rgba(5,7,15,.72); }
.panel {
  width: min(94vw, 720px); text-align: center; padding: 22px 18px; margin: auto;
  background: rgba(8,12,32,.9); border: 4px solid #fff; border-radius: 12px; box-shadow: 0 0 0 4px #d62b2b, 0 14px 40px rgba(0,0,0,.5);
}
.panel.clear { background: none; border: 0; box-shadow: none; }
h1 { font-size: clamp(20px, 5vw, 44px); line-height: 1.3; margin: 0 0 6px; color: #fff; text-shadow: 4px 4px 0 #d62b2b, 8px 8px 0 #0b2545; }
h2 { font-size: clamp(14px, 3vw, 22px); color: #ffd75e; margin: 0 0 14px; }
.sub { font-size: clamp(8px, 1.5vw, 11px); color: #cfe6ff; margin: 0 0 20px; line-height: 1.8; }
.btn {
  display: inline-block; margin: 6px; padding: 14px 20px; min-width: 200px; font-size: clamp(10px, 1.8vw, 13px);
  color: #fff; background: #d62b2b; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 5px 0 #7a1010;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #7a1010; }
.btn.alt { background: #1f6f4a; box-shadow: 0 5px 0 #0d3a25; }
.btn.ghost { background: transparent; box-shadow: none; min-width: 0; font-size: 10px; }
.row { display: flex; flex-wrap: wrap; justify-content: center; }

.sponsors { margin-top: 18px; }
.sponsors .label { font-size: 9px; color: #9ab; margin-bottom: 10px; }
.sp-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sp {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; min-width: 170px; text-decoration: none;
  border: 2px solid; border-radius: 8px; font-size: 11px; color: #fff;
}
.sp small { font-size: 7px; opacity: .85; line-height: 1.5; }
a.sp:hover { transform: translateY(-2px); }

.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.lvl {
  padding: 12px 8px; font-size: 10px; color: #fff; background: #13204a; border: 3px solid #4a6aa8; border-radius: 8px; line-height: 1.8;
}
.lvl small { display: block; font-size: 7px; color: #9ab; }
.lvl .st { color: #ffd75e; font-size: 12px; }
.lvl.locked { opacity: .4; cursor: not-allowed; }
.stars { font-size: 34px; color: #ffd75e; letter-spacing: 8px; margin: 6px 0 12px; }
.stars .off { color: #3a4060; }
.stats { font-size: 11px; line-height: 2.2; color: #e8eef8; margin-bottom: 10px; }
.stats b { color: #ffd75e; font-weight: normal; }
.credits { font-size: 10px; line-height: 2.2; color: #cfe6ff; }
.credits b { color: #ffd75e; font-weight: normal; }
.howto { font-size: 9px; line-height: 2; color: #cfe6ff; margin: 8px 0 4px; }
.howto b { color: #ffd75e; font-weight: normal; }

#rotate {
  position: absolute; inset: 0; z-index: 20; background: #0a1030; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; font-size: 12px; line-height: 1.8; padding: 24px;
}
.rot-phone { width: 46px; height: 80px; border: 4px solid #fff; border-radius: 8px; animation: rot 2s ease-in-out infinite; margin-bottom: 24px; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

@media (max-height: 480px) {
  .panel { padding: 12px; }
  h1 { font-size: 20px; }
  .sub { margin-bottom: 10px; }
  .btn { padding: 10px 14px; min-width: 150px; margin: 4px; }
  .sponsors { margin-top: 8px; }
  .sp { min-width: 140px; padding: 6px 8px; }
  #dialog { min-height: 80px; padding: 10px 14px 24px; }
  .tbtn { width: 62px; height: 62px; }
  .tbtn.big { width: 80px; height: 80px; }
}
