/* ============================================================
   style.css — page layout, the crisp pixel stage, the DOM UI
   overlay (dialogs/menus/HUD), touch controls and the ad slot.
   --u = size of one game pixel in CSS px (set by main.js).
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; background: #0b0d1a; color: #e8ecff; font-family: "Courier New", ui-monospace, Menlo, Consolas, monospace; }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: #46f0ff; }
#wrap { display: flex; flex-direction: column; align-items: center; padding: 8px 0 16px; }

/* ---------- the game stage ---------- */
#play { display: grid; grid-template-areas: "stage"; justify-content: center; align-items: center; gap: 8px; }
#stage { grid-area: stage; position: relative; width: 320px; height: 180px; --u: 1px; background: #000; box-shadow: 0 0 0 2px #2a2f5e, 0 0 30px rgba(70, 240, 255, .15); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#screen { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#ui { position: absolute; inset: 0; pointer-events: none; font-size: max(11px, calc(var(--u) * 6.4)); line-height: 1.3; font-weight: bold; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.keys { color: #6a70a0; font-size: 12px; margin: 8px 0 0; text-align: center; }

/* ---------- boxes ---------- */
.box { position: absolute; background: rgba(12, 14, 36, .94); border: max(2px, calc(var(--u) * 1)) solid #c9d3e6; border-radius: calc(var(--u) * 2); box-shadow: 0 0 0 max(2px, calc(var(--u) * 1)) #14121f, inset 0 0 0 max(1px, calc(var(--u) * .5)) #3a3f8f; padding: .55em .8em; color: #f2f4ff; }
.dialog { left: 3%; right: 3%; bottom: 3%; min-height: 26%; }
.dialog.top { top: 3%; bottom: auto; min-height: 0; }
.dialog .name { position: absolute; top: -1.05em; left: .6em; background: #3a6df0; color: #fff; padding: 0 .5em; border: 2px solid #c9d3e6; border-radius: 4px; font-size: .9em; }
.dialog .txt { white-space: pre-wrap; text-shadow: 1px 1px 0 #000; }
.dialog .more { position: absolute; right: .6em; bottom: .2em; color: #46f0ff; animation: bob .6s infinite alternate; }
@keyframes bob { to { transform: translateY(3px); } }
.menu { min-width: 34%; max-height: 92%; display: flex; flex-direction: column; }
.menu.right { right: 3%; top: 4%; }
.menu.center, .panel.center { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.menu.choice { right: 3%; bottom: 33%; min-width: 30%; }
.menu.bl { left: 3%; bottom: 3%; min-width: 34%; max-height: 62%; }
.menu.title-menu { left: 50%; transform: translateX(-50%); bottom: 3%; min-width: 40%; padding: .3em .8em; background: rgba(12, 14, 36, .82); }
.menu .title, .panel .title { color: #ffd447; margin-bottom: .3em; text-shadow: 1px 1px 0 #000; }
.menu .list { overflow-y: auto; }
.row { display: flex; gap: .4em; padding: .08em .2em; cursor: pointer; white-space: nowrap; }
.row .cur { visibility: hidden; color: #46f0ff; }
.row.sel { background: rgba(70, 240, 255, .15); }
.row.sel .cur { visibility: visible; }
.row .lbl { flex: 1; }
.row .rt { color: #9aa2c8; }
.row.off { color: #6a70a0; }
.menu .desc { color: #9fd0ff; font-size: .85em; margin-top: .3em; min-height: 1.2em; white-space: normal; max-width: 22em; }
.msg { left: 3%; right: 3%; top: 3%; text-align: center; }

/* ---------- info panels ---------- */
.panel { left: 4%; right: 4%; top: 5%; bottom: 5%; display: flex; flex-direction: column; }
.panel .body { overflow-y: auto; flex: 1; font-weight: normal; }
.panel .body p { margin: .35em 0; }
.panel .body ul { margin: .2em 0; padding-left: 1.2em; }
.panel .off, .panel .ach.off { color: #6a70a0; }
.panel .ach.on b { color: #ffd447; }
.panel .hint { color: #46f0ff; font-size: .85em; text-align: right; margin-top: .3em; cursor: pointer; }
.panel button, .board button { font: inherit; background: #2a2f5e; color: #fff; border: 2px solid #c9d3e6; border-radius: 4px; padding: .2em .6em; cursor: pointer; }
.panel button.sel, .panel button:hover { background: #3a6df0; }
.panel button.hot { background: #b02a6a; }
.panel button.hot.sel { background: #ff4f9a; }
.board .tabs { display: flex; gap: .4em; }
.board .tabs button.on { background: #46f0ff; color: #0b0d1a; }
.board .filter { display: flex; align-items: center; gap: .6em; margin: .3em 0; }
.board table { width: auto; min-width: 70%; border-collapse: collapse; }
.board td:nth-child(2) { min-width: 9em; }
.board td { padding: .05em .3em; }
.board tr.me { background: rgba(255, 212, 71, .25); color: #ffd447; }
.board .note { color: #ff8a3d; font-size: .8em; }
.name-entry { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: 80%; gap: .4em; }
.name-entry input { font: inherit; font-size: 1.2em; padding: .2em .4em; background: #06081a; color: #46f0ff; border: 2px solid #46f0ff; border-radius: 4px; }
.name-entry input.bad { border-color: #ff4f6d; }
.small { font-size: .8em; color: #9aa2c8; font-weight: normal; }
.btns { display: flex; flex-wrap: wrap; gap: .4em; }
.share { top: 3%; bottom: 3%; left: 3%; right: 3%; align-items: center; overflow-y: auto; }
.share img { width: auto; max-width: 70%; max-height: 52%; image-rendering: auto; border: 2px solid #46f0ff; margin: .2em 0; }
.share .rank { color: #ffd447; margin: .2em 0; }
.share .btns { justify-content: center; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none !important; font-size: .78em; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.hud .hl { position: absolute; left: 2%; top: 2%; background: rgba(0, 0, 0, .55); padding: .1em .4em; border-radius: 4px; }
.hud .spill { color: #ff8a3d; }
.hud .hs { position: absolute; left: 2%; top: 13%; background: rgba(0, 0, 0, .55); padding: .2em .4em; border-radius: 4px; line-height: 1.25; }
.hud .hr { position: absolute; right: 2%; top: 2%; background: rgba(0, 0, 0, .55); padding: .1em .4em; border-radius: 4px; color: #ffd447; }
.hud.battle .hs { left: auto; right: 2%; top: auto; bottom: 4%; font-size: 1.15em; background: rgba(12, 14, 36, .92); border: 2px solid #c9d3e6; }
.hud.battle .hr { display: none; }
.hud.battle .hl { top: auto; bottom: 1%; left: auto; right: 40%; background: none; font-size: .9em; }
.bar { display: inline-block; width: 4.2em; height: .55em; background: #14121f; border: 1px solid #6a70a0; vertical-align: middle; }
.bar i { display: block; height: 100%; background: #7cff6b; }
.bar.en i { background: #46f0ff; }
.inf { color: #ff4f9a; }
.pip { color: #ffb347; }

/* ---------- toasts ---------- */
.toasts { position: absolute; left: 50%; top: 2%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: .3em; pointer-events: none !important; z-index: 5; }
.toast { background: rgba(20, 18, 31, .92); border: 2px solid #46f0ff; color: #fff; padding: .15em .6em; border-radius: 4px; font-size: .85em; transition: opacity .5s; white-space: nowrap; }
.toast.gold { border-color: #ffd447; color: #ffd447; }
.toast.out { opacity: 0; }

/* ---------- title + credits ---------- */
.logo { position: absolute; left: 0; right: 0; top: 7%; text-align: center; pointer-events: none !important; }
.logo .l1 { font-size: 3.6em; color: #46f0ff; letter-spacing: .08em; text-shadow: 3px 3px 0 #1f2a8a, 0 0 18px rgba(70, 240, 255, .6); line-height: 1; }
.logo .l2 { font-size: 1.5em; color: #ffd447; text-shadow: 2px 2px 0 #5a3a00; letter-spacing: .15em; }
.logo .l3 { font-size: .85em; color: #ff8a3d; margin-top: .3em; text-shadow: 1px 1px 0 #000; }
.credits { position: absolute; inset: 0; overflow: hidden; text-align: center; text-shadow: 2px 2px 0 #000; }
.credits .roll { position: absolute; left: 0; right: 0; top: 100%; animation: roll 22s linear forwards; }
@keyframes roll { to { transform: translateY(-235%); } }
.credits h1 { color: #46f0ff; margin: .2em 0; font-size: 2.2em; } .credits h1.thanks { color: #ffd447; margin-top: 1.5em; }
.credits h2 { color: #ffd447; margin: 0 0 .5em; } .credits h3 { color: #ff8a3d; margin: 1.1em 0 .2em; } .credits p { margin: .2em 0; }
.credits .hint { position: absolute; right: 2%; bottom: 2%; color: #46f0ff; font-size: .8em; }
.ghost { display: none; }

/* ---------- touch controls ---------- */
.touch-only { display: none; }
body.touch .touch-only { display: grid; }
body.touch .desk-only { display: none; }
#dpad { grid-area: dpad; grid-template: repeat(3, 52px) / repeat(3, 52px); }
#dpad .up { grid-area: 1 / 2; } #dpad .left { grid-area: 2 / 1; } #dpad .right { grid-area: 2 / 3; } #dpad .down { grid-area: 3 / 2; }
#btns { grid-area: btns; grid-template: 52px 64px / 64px 64px; gap: 8px; align-items: center; justify-items: center; }
#btns .menu { grid-area: 1 / 1 / 2 / 3; width: 56px; height: 36px; border-radius: 18px; font-size: 18px; }
#btns .b { grid-area: 2 / 1; } #btns .a { grid-area: 2 / 2; transform: translateY(-14px); }
#play button[data-k] { background: #2a2f5e; color: #e8ecff; border: 2px solid #6a70d0; font: bold 20px "Courier New", monospace; touch-action: none; user-select: none; -webkit-user-select: none; }
#dpad button { border-radius: 8px; }
#btns .a, #btns .b { width: 60px; height: 60px; border-radius: 50%; font-size: 24px; }
#btns .a { background: #b02a6a; border-color: #ff7ab8; } #btns .b { background: #2643a8; border-color: #46f0ff; }
#play button.on { filter: brightness(1.6); transform: scale(.94); }
#btns .a.on { transform: translateY(-14px) scale(.94); }
body.touch.portrait #play { grid-template-areas: "stage stage" "dpad btns"; grid-template-columns: 1fr 1fr; width: 100%; padding: 0 6px; row-gap: 14px; }
body.touch.portrait #stage { justify-self: center; }
body.touch.portrait #dpad { justify-self: start; margin-left: 4px; }
body.touch.portrait #btns { justify-self: end; margin-right: 4px; }
body.touch.landscape #play { grid-template-areas: "dpad stage btns"; }
body.touch.landscape #wrap { padding-top: 4px; }

/* ---------- ad slot (never overlaps the game: it is in normal flow below it) ---------- */
.ad-slot { width: 728px; max-width: 100%; height: 90px; margin: 14px auto 0; position: relative; background: #12142a; border: 1px dashed #3a3f6a; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-label { position: absolute; top: 2px; left: 6px; font-size: 10px; color: #6a70a0; text-transform: uppercase; letter-spacing: .1em; }
.ad-placeholder { color: #3a3f6a; font-size: 14px; }
@media (max-width: 760px) { .ad-slot { width: 320px; height: 100px; } }

footer { text-align: center; color: #9aa2c8; font-size: 13px; margin-top: 14px; padding: 0 10px; }
footer p { margin: 4px 0; }
footer .more { font-weight: bold; }
