:root {
  --bg: #05050b;
  --ink: #f4efe6;
  --gold: #ffd166;
  --rose: #ff6b8b;
  --panel: #14141f;
  --line: #2b2b40;
  --text: "Rubik", system-ui, -apple-system, sans-serif;    /* clear letters, Russian + Kazakh */
  --head: "Press Start 2P", "Rubik", monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none;
  font-family: var(--text); font-weight: 500;
}
#app {
  height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- screen ---------- */
#stage {
  position: relative; width: min(100vw, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9;
  container-type: inline-size; background: #000; flex: none; overflow: hidden;
}
#screen { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#ui { position: absolute; inset: 0; pointer-events: none; font-size: 3.2cqw; line-height: 1.25; }
#ui > * { pointer-events: auto; }

.px-box {
  background: #05050bf2; color: var(--ink);
  border: .55cqw solid var(--ink); box-shadow: 0 0 0 .3cqw #05050b, 0 1cqw 0 .3cqw #00000055;
}

/* full screen button */
#full {
  position: absolute; top: 1.2cqw; right: 1.4cqw; width: 5.6cqw; height: 5.6cqw; min-width: 26px; min-height: 26px; padding: 0;
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
  background: #05050bcc; border: .3cqw solid #ffffff55; border-radius: 0; z-index: 5;
}
#full svg { width: 58%; height: 58%; }
#full:hover { border-color: var(--gold); color: var(--gold); }

/* title: everything sits in the sky so the two characters on the ground stay visible */
.title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 2cqw; text-align: center; pointer-events: none; }
.title h1 {
  margin: 0; font-family: var(--head); font-weight: 400;
  font-size: 5.4cqw; letter-spacing: .1cqw; color: var(--gold);
  text-shadow: .55cqw .55cqw 0 #7a3b12, -0.28cqw 0 0 #05050b, 0 -0.28cqw 0 #05050b, .28cqw 0 0 #05050b;
}
.title .sub { margin-top: .9cqw; font-size: 2.9cqw; font-weight: 600; color: #fff; text-shadow: .28cqw .28cqw 0 #05050b; }
.title .menu { margin-top: 1.3cqw; padding: .4cqw 2.4cqw .7cqw; min-width: 36cqw; text-align: left; pointer-events: auto; }
.title .menu .it { display: flex; gap: 1.4cqw; padding: .1cqw 0; font-size: 2.9cqw; font-weight: 600; color: #9b98a8; cursor: pointer; }
.title .menu .it::before { content: "▸"; color: transparent; }
.title .menu .it.on { color: #fff; }
.title .menu .it.on::before { color: var(--gold); }
.title .foot { position: absolute; bottom: 1.4cqw; left: 0; right: 0; font-size: 2.5cqw; color: #e6e1f2; text-shadow: .28cqw .28cqw 0 #05050b; }

/* hud */
.hud { position: absolute; top: 1.2cqw; left: 1.4cqw; right: 8.6cqw; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none !important; font-size: 2.7cqw; font-weight: 600; }
.hud .chip { background: #05050bcc; padding: .5cqw 1.4cqw .7cqw; border: .3cqw solid #ffffff55; height: 5.6cqw; min-height: 26px; display: flex; align-items: center; gap: .6cqw; white-space: nowrap; }
.hud .chip b { color: var(--gold); font-weight: 700; }
.hud .hearts { color: var(--rose); }

/* dialog */
.dialog { position: absolute; left: 3cqw; right: 3cqw; bottom: 2.4cqw; padding: 2cqw 2.6cqw 2.4cqw; min-height: 19cqw; cursor: pointer; }
.dialog .who { position: absolute; top: -3.6cqw; left: 2cqw; padding: .3cqw 1.6cqw .4cqw; font-size: 2.6cqw; font-weight: 700; letter-spacing: .05cqw; background: var(--gold); color: #1a1208; }
.dialog .txt { font-size: 3.5cqw; line-height: 1.28; white-space: pre-wrap; }
.dialog .next { position: absolute; right: 1.8cqw; bottom: .8cqw; font-size: 2.6cqw; color: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* scenes with big characters keep the text at the top so it does not cover them */
#ui.top .dialog { bottom: auto; top: 10cqw; min-height: 0; }

/* answer options under a dialog line */
.dialog .opts { display: flex; gap: 2.4cqw; margin-top: 1.6cqw; justify-content: center; }
.dialog .opt { min-width: 22cqw; text-align: center; padding: .7cqw 2cqw .8cqw; font-size: 3.1cqw; font-weight: 700; color: #a9a4bb; border: .4cqw solid #55506a; cursor: pointer; }
.dialog .opt.on { color: #1a1208; background: var(--gold); border-color: #fff3c4; }

/* chat bubbles in the night chat */
.bubble { position: absolute; transform: translate(-50%, -100%); max-width: 44cqw; padding: .8cqw 1.8cqw 1cqw; font-size: 2.9cqw; line-height: 1.2; text-align: center; pointer-events: none !important; animation: bub .25s ease-out; }
.bubble.him { background: #2b5278; color: #fff; border: .3cqw solid #9fd0ff; }
.bubble.her { background: #f4efe6; color: #1a1208; border: .3cqw solid #ff9fb6; }
.bubble.clock { transform: translate(-50%, 0); background: #05050bcc; border: .3cqw solid #ffffff55; color: var(--gold); font-family: var(--head); font-size: 3cqw; padding: 1cqw 2cqw; }
@keyframes bub { from { transform: translate(-50%, -80%) scale(.7); opacity: 0; } }

/* toast (collected word) */
.toast { position: absolute; top: 10cqw; left: 50%; transform: translateX(-50%); padding: .7cqw 2.6cqw .9cqw; font-size: 3.3cqw; font-weight: 600; color: #fff; background: #b3274f; border: .3cqw solid #ffd0dc; white-space: nowrap; animation: pop 2.2s ease forwards; pointer-events: none !important; }
@keyframes pop { 0% { transform: translate(-50%, 2cqw) scale(.8); opacity: 0; } 12% { transform: translate(-50%, 0) scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -2cqw); opacity: 0; } }

/* cards (chapter / end) */
.card { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #05050bee; padding: 4cqw; cursor: pointer; z-index: 6; }
.card.clear { background: #05050b88; }
.card.clear h2, .card.clear p, .card.clear .k { text-shadow: .3cqw .3cqw 0 #05050b; }
.card .k { font-family: var(--head); font-size: 2.4cqw; color: var(--gold); letter-spacing: .3cqw; }
.card h2 { margin: 2cqw 0 1.4cqw; font-family: var(--head); font-weight: 400; font-size: 4.4cqw; color: #fff; }
.card p { margin: .5cqw 0; font-size: 3.2cqw; color: #d8d3e6; max-width: 80cqw; }
.card .list { margin-top: 1.6cqw; text-align: left; font-size: 2.9cqw; color: #a9a4bb; columns: 2; column-gap: 5cqw; }
.card .list div::before { content: "· "; color: var(--gold); }
.card .recs { margin-top: 1.6cqw; min-width: 56cqw; font-size: 3cqw; text-align: left; }
.card .recs div { display: flex; gap: 2cqw; align-items: baseline; padding: .5cqw 0; border-bottom: .2cqw solid #ffffff22; }
.card .recs span { flex: 1; color: #d8d3e6; }
.card .recs b { color: #fff; font-weight: 700; }
.card .recs i { color: var(--gold); font-style: normal; font-weight: 700; font-size: 2.4cqw; }
.card .hint { margin-top: 2.6cqw; font-size: 2.8cqw; font-weight: 600; color: var(--gold); animation: blink 1s steps(2) infinite; }

/* minigame banner */
.mg-top { position: absolute; top: 1.8cqw; left: 0; right: 0; text-align: center; font-size: 2.9cqw; font-weight: 700; letter-spacing: .1cqw; text-shadow: .28cqw .28cqw 0 #05050b; pointer-events: none !important; }
.mg-top b { color: var(--gold); font-weight: 700; }

/* ---------- touch controls ---------- */
#pad { flex: 1; width: 100%; max-width: 560px; display: flex; align-items: center; justify-content: space-between; padding: 12px 22px 18px; gap: 12px; min-height: 0; }
.dpad { position: relative; width: 168px; height: 168px; flex: none; }
.pb {
  appearance: none; border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  font-family: inherit; font-size: 20px; border-radius: 14px; display: grid; place-items: center;
  touch-action: none; cursor: pointer; box-shadow: 0 4px 0 #000; transition: transform .04s;
}
.pb.on { transform: translateY(3px); box-shadow: 0 1px 0 #000; background: #23233a; border-color: var(--gold); }
.dpad .pb { position: absolute; width: 56px; height: 56px; }
.dpad .up { left: 56px; top: 0; }
.dpad .down { left: 56px; top: 112px; }
.dpad .left { left: 0; top: 56px; }
.dpad .right { left: 112px; top: 56px; }
.ab { display: flex; align-items: flex-end; gap: 14px; }
.ab .pb { width: 78px; height: 78px; border-radius: 50%; font-size: 26px; display: flex; flex-direction: column; justify-content: center; gap: 0; }
.ab .pb small { font-size: 12px; opacity: .7; }
.ab .a { background: #3a1626; border-color: #a33a5f; margin-bottom: 28px; }
.ab .b { background: #14263a; border-color: #2f6ea3; }

/* phone held sideways: the game fills the screen, buttons float over its edges */
@media (orientation: landscape) {
  #app { justify-content: center; }
  #pad { position: fixed; inset: auto 0 0 0; max-width: none; padding: 0 22px 14px; pointer-events: none; opacity: .5; }
  #pad .pb { pointer-events: auto; }
  .dpad { transform: scale(.8); transform-origin: left bottom; }
  .ab { transform: scale(.8); transform-origin: right bottom; }
}

/* keyboard: no touch buttons, a one-line legend under the screen instead */
#keys { display: none; }
body.keys #pad { display: none; }
body.keys #app { justify-content: center; gap: 10px; }
body.keys #stage { width: min(100vw, calc((100dvh - 44px) * 16 / 9)); }
body.keys #keys { display: block; flex: none; font-size: 15px; color: #a9a4bb; text-align: center; padding: 0 12px; }

/* "max" mode: fallback where the browser has no real full screen */
body.max #keys { display: none !important; }
body.max #stage { width: min(100vw, calc(100dvh * 16 / 9)) !important; }
body.max #app { justify-content: center; padding: 0; }
body.max #full { border-color: var(--gold); color: var(--gold); }

/* real full screen: nothing but the game */
:fullscreen #keys, :-webkit-full-screen #keys { display: none !important; }
:fullscreen #stage, :-webkit-full-screen #stage { width: min(100vw, calc(100dvh * 16 / 9)) !important; }
:fullscreen #app, :-webkit-full-screen #app { justify-content: center; padding: 0; }
