* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b1020; color: #eef2ff; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; }

.langs { position: fixed; top: 6px; right: 6px; z-index: 30; display: flex; gap: 4px; }
.langbtn { background: rgba(0,0,0,.55); color: #cfd6ff; border: 1px solid #3c4680; border-radius: 6px; padding: 3px 8px; font: 700 12px system-ui; cursor: pointer; }
.langbtn.on { background: #ffd23b; color: #111; border-color: #ffd23b; }

.game { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stage { position: relative; width: min(100vw, calc((100vh - var(--ctl, 0px)) * 16 / 9)); aspect-ratio: 16 / 9; background: #000; }
#cv { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.mini { position: absolute; bottom: 6px; right: 6px; width: 32px; height: 28px; border: 1px solid #3c4680; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px; font-size: 13px; cursor: pointer; }
.mini.p2 { right: 44px; }

.touch { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 6px 14px 12px; gap: 10px; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch[hidden] { display: none; }
.pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px; }
.pad [data-k=L] { grid-area: 2 / 1; } .pad [data-k=R] { grid-area: 2 / 3; } .pad [data-k=U] { grid-area: 1 / 2; } .pad [data-k=D] { grid-area: 2 / 2; }
.acts { display: flex; gap: 12px; }
.tb { width: 56px; height: 56px; border-radius: 14px; border: 2px solid #4a58a8; background: rgba(40,52,110,.75); color: #fff; font: 700 18px system-ui; touch-action: none; user-select: none; -webkit-user-select: none; }
.tb.big { width: 92px; height: 78px; font-size: 14px; border-radius: 40px; }
.tb.f { background: rgba(190,50,60,.8); border-color: #ff7a85; }
.tb.on { filter: brightness(1.7); transform: scale(.95); }
@media (orientation: landscape) and (max-height: 520px) {
  .game { position: relative; }
  .touch { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 18px 10px; pointer-events: none; }
  .touch .tb { pointer-events: auto; opacity: .55; }
  .pad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(2, 50px); }
  .tb { width: 50px; height: 50px; }
  .tb.big { width: 84px; height: 66px; }
}

.panel { position: fixed; inset: 0; z-index: 20; background: rgba(8,12,28,.94); overflow-y: auto; padding: 44px 18px 24px; display: flex; flex-direction: column; align-items: center; }
.panel[hidden], .endbar[hidden] { display: none; }
.panel > * { width: min(520px, 100%); }
.panel.small { background: rgba(8,12,28,.8); justify-content: center; text-align: center; }
h1 { margin: 6px 0 2px; font: 900 34px/1.1 ui-monospace, Consolas, monospace; letter-spacing: 2px; color: #ffd23b; text-shadow: 3px 3px 0 #b3261e; text-align: center; }
h2 { font-size: 15px; margin: 14px 0 6px; color: #9fb0ff; }
.tag { text-align: center; color: #cfd6ff; margin: 4px 0 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #9fb0ff; margin-bottom: 10px; }
input { background: #121a38; border: 1px solid #3c4680; color: #fff; border-radius: 8px; padding: 10px 12px; font: 600 16px system-ui; min-width: 0; }
input#code { width: 120px; text-transform: uppercase; text-align: center; letter-spacing: 3px; }
.btns { display: flex; flex-direction: column; gap: 8px; }
.btns.row { flex-direction: row; justify-content: center; }
.btn { background: #1a2550; color: #fff; border: 2px solid #4a58a8; border-radius: 10px; padding: 12px 14px; font: 700 15px system-ui; cursor: pointer; }
.btn:hover { background: #26347a; }
.btn.primary { background: #c9302c; border-color: #ff7a6b; }
.btn.primary:hover { background: #e03b36; }
.joinrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #9fb0ff; }
.joinrow span { flex: 1; }
.msg { min-height: 18px; text-align: center; color: #ffb4a8; font-size: 14px; }
.how { margin-top: 10px; font-size: 13px; color: #b8c2f0; line-height: 1.45; }
.how p { margin: 3px 0; }
.code { font-family: ui-monospace, Consolas, monospace; color: #7dff8a; letter-spacing: 4px; text-shadow: none; }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; font-size: 13px; }
.slots { list-style: none; padding: 0; margin: 14px 0; }
.slots li { background: #121a38; border: 1px solid #3c4680; border-radius: 8px; padding: 10px 12px; margin: 6px 0; font-weight: 700; }
.slots li.empty { color: #7a86c0; font-weight: 400; }
.endbar { position: fixed; left: 0; right: 0; bottom: 8px; z-index: 15; display: flex; justify-content: center; gap: 10px; }
@media (max-width: 480px) { h1 { font-size: 28px; } }
