@font-face { font-family: Pixel; src: url(/fonts/ps2p-cyrillic.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: block; }
@font-face { font-family: Pixel; src: url(/fonts/ps2p-latin.woff2) format('woff2'); font-display: block; }
:root { --ink: #2a3350; --cream: #fff6dc; --gold: #ffc53d; --green: #36b37e; --sky: #dff5f5; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); overscroll-behavior: none; }
body { font-family: Pixel, monospace; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; position: fixed; inset: 0; }
[hidden] { display: none !important; }
#game { position: absolute; inset: 0; }
#game canvas { display: block; image-rendering: pixelated; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); pointer-events: none; font-size: 14px; }
.hud-left, .hud-right { display: flex; gap: 10px; align-items: center; }
.stat { display: flex; align-items: center; gap: 6px; background: var(--ink); color: var(--cream); padding: 6px 10px; border-radius: 4px; box-shadow: 0 3px 0 #0003; }
.ico { width: 18px; height: 18px; background: url(/assets/tiles.png); image-rendering: pixelated; display: block; }
.ico.coin { background-position: -198px -126px; }
.ico.gem { background-position: -126px -54px; }
#room-badge { background: var(--ink); color: var(--cream); padding: 8px 10px; border-radius: 4px; font-size: 12px; }
#room-badge.online { color: #7dffb2; }
#mute, #to-friend { pointer-events: auto; background: var(--cream); border: 0; border-radius: 4px; box-shadow: 0 3px 0 #0005; padding: 10px 12px; font-size: 12px; min-height: 40px; }
#mute.off { opacity: .5; text-decoration: line-through; }
#to-friend { background: var(--gold); }

#touch { position: absolute; inset: 0; touch-action: none; z-index: 1; }
#hud { z-index: 2; }
#stick { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
#stick::before { content: ''; position: absolute; left: -32px; top: -32px; width: 64px; height: 64px; border-radius: 50%; border: 3px solid #fff8; }
#knob { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%; background: #ffc53dbb; }
#hint { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); background: var(--ink); color: var(--cream); padding: 10px 14px; border-radius: 6px; font-size: 11px; line-height: 2; text-align: center; white-space: nowrap; pointer-events: none; animation: nudge 1.2s infinite ease-in-out; }
#hint b { color: var(--gold); font-weight: normal; }
@keyframes nudge { 50% { margin-bottom: 5px; } }

#menu { z-index: 3; position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; overflow: auto; touch-action: pan-y; }
.panel { background: var(--cream); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 6px 0 #0005; padding: 14px 16px; text-align: center; max-width: 620px; width: 100%; }
h1 { font-size: clamp(24px, 7vmin, 44px); margin: 2px 0 8px; font-weight: normal; color: var(--green); text-shadow: 3px 3px 0 var(--ink); letter-spacing: 2px; }
.sub { font-size: 12px; line-height: 1.6; margin: 6px 0 10px; }
.err { color: #c8372d; min-height: 20px; margin: 6px 0 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.big { background: var(--gold); border: 3px solid var(--ink); border-radius: 6px; box-shadow: 0 4px 0 var(--ink); padding: 14px 12px; font-size: 12px; min-height: 52px; flex: 1 1 150px; line-height: 1.4; }
.big.alt { background: #fff; }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#heroes { display: flex; gap: 6px; justify-content: center; }
.hero { width: 76px; height: 76px; border: 3px solid transparent; border-radius: 8px; background: none; padding: 0; display: grid; place-items: center; }
.hero.sel { border-color: var(--ink); background: var(--gold); }
.hero i { display: block; width: 24px; height: 24px; background: url(/assets/chars.png); image-rendering: pixelated; transform: scale(2.6); }
#code, #entry { font-size: 40px; letter-spacing: 12px; padding-left: 12px; margin: 4px 0; color: var(--ink); }
#keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
#keys button { background: #fff; border: 3px solid var(--ink); border-radius: 6px; font-size: 18px; min-height: 52px; box-shadow: 0 3px 0 var(--ink); }
#keys button:active { background: var(--gold); }
#win-stats { display: flex; gap: 16px; justify-content: center; font-size: 16px; }

#rotate { position: absolute; inset: 0; background: var(--ink); color: var(--cream); display: grid; place-content: center; justify-items: center; gap: 22px; font-size: 13px; text-align: center; padding: 20px; line-height: 1.6; z-index: 5; }
#rotate p { margin: 0; }
.phone { width: 54px; height: 94px; border: 5px solid var(--cream); border-radius: 10px; animation: turn 2s infinite ease-in-out; }
@keyframes turn { 0%, 30% { transform: rotate(0); } 70%, 100% { transform: rotate(90deg); } }
@media (max-height: 420px) { .panel { padding: 8px 12px; } .sub { margin: 3px 0 5px; font-size: 11px; } .row { margin-top: 6px; } .big { padding: 8px; min-height: 46px; } #keys button { min-height: 44px; } }
