/* ==========================================================================
   ИХТИАНДР — RPG design system (build register)
   Уютное JRPG-меню на берегу ночного озера. Handjet + JetBrains Mono.
   Palette: deep lake water (H200-210) + gold menus (H85) + biolum cyan (H190).
   ========================================================================== */
@import url("/fonts/fonts.css");

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
button, input, textarea { font: inherit; color: inherit; background: transparent; border: 0; outline: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }

/* ---- tokens ---- */
:root {
  --bg-abyss:  #071115;
  --bg-deep:   #0a1519;
  --bg:        #0e2029;
  --bg-panel:  #133039;
  --bg-panel2: #17394330;

  --ink:       #e7f3f2;   /* body — high contrast on deep water */
  --ink-soft:  #a9c8c9;   /* secondary */
  --ink-dim:   #6f9296;   /* labels; still ≥4.5 on --bg */

  --gold:      #f2c751;   /* RPG menu frames / XP / primary accent */
  --gold-hi:   #ffe08a;
  --gold-deep: #9a7327;

  --cyan:      #45e3d2;   /* magic / water / anomaly */
  --cyan-deep: #1f7d78;
  --coral:     #ff8193;   /* heart — final only */
  --danger:    #ff6b52;

  --display: "Handjet", "JetBrains Mono", monospace;
  --body:    "JetBrains Mono", ui-monospace, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);

  --panel-edge: 0 0 0 1px var(--gold-deep), 0 0 0 3px #0c1c22, 0 0 0 4px #23424c,
                inset 0 0 22px rgba(0,0,0,.55), 0 8px 30px rgba(0,0,0,.45);
}

/* ---- base ---- */
html { background: var(--bg-abyss); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #14313b 0%, var(--bg-deep) 46%, var(--bg-abyss) 100%);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

/* water host — canvas (js/water.js) draws caustics, rays, motes below content */
.waterbed { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

/* faint scanline sheen — the "console screen" feel, very subtle (not CRT-green) */
.screen-sheen {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.10) 3px, rgba(0,0,0,0) 4px);
  mix-blend-mode: multiply; opacity: .5;
}

/* ---- layout shell ---- */
.stage {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-top)) 16px calc(18px + var(--safe-bot));
  max-width: 620px; margin: 0 auto;
}

/* ---- HUD topbar ---- */
.hud-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: 1px solid #21414a; padding-bottom: 8px;
}
.hud-top b { color: var(--gold); font-weight: 700; }
.hud-top .dot { color: var(--cyan); }

/* ---- typography ---- */
.logo {
  font-family: var(--display);
  font-weight: 700;
  line-height: .82;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: clamp(3.4rem, 20vw, 6rem);
  color: var(--gold);
  text-shadow:
    0 0 1px var(--gold-hi),
    0 3px 0 var(--gold-deep),
    0 4px 0 #5c440f,
    0 6px 18px rgba(242,199,81,.28);
}
.tagline {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1rem, 4.5vw, 1.4rem); letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--cyan);
  text-shadow: 0 0 10px rgba(69,227,210,.4);
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; text-transform: uppercase; line-height: .95; }
h2 { font-size: clamp(1.5rem, 6vw, 2.1rem); color: var(--gold); letter-spacing: .04em;
     text-shadow: 0 2px 0 var(--gold-deep), 0 0 14px rgba(242,199,81,.22); }
h3 { font-size: 1.15rem; color: var(--cyan); letter-spacing: .06em; }

.mono-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); }
.soft { color: var(--ink-soft); }
.center { text-align: center; }

/* ---- JRPG panel ---- */
.panel {
  position: relative;
  background: linear-gradient(180deg, #143039, #0d2027);
  box-shadow: var(--panel-edge);
  padding: 18px 16px;
}
.panel::before {
  /* corner ticks — the menu-frame feel without border-left slop */
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  background:
    linear-gradient(var(--gold),var(--gold)) 0 0/12px 2px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 0 0/2px 12px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 100% 0/12px 2px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 100% 0/2px 12px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 0 100%/12px 2px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 0 100%/2px 12px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 100% 100%/12px 2px no-repeat,
    linear-gradient(var(--gold),var(--gold)) 100% 100%/2px 12px no-repeat;
  opacity: .8;
}

/* ---- boot log ---- */
.bootlog { font-size: 12px; line-height: 1.7; color: var(--ink-dim); letter-spacing: .04em; }
.bootlog .ok  { color: var(--cyan); }
.bootlog b { color: var(--ink-soft); font-weight: 400; }

/* ---- press start ---- */
.press-start {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.3rem, 6vw, 1.7rem); letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold-hi);
  text-shadow: 0 0 12px rgba(242,199,81,.5);
  animation: ps-blink 1.15s steps(2,end) infinite;
}
@keyframes ps-blink { 0%,55% { opacity: 1 } 56%,100% { opacity: .18 } }

/* ---- form / menu buttons ---- */
.field {
  display: block; width: 100%; padding: 13px 14px; margin: 10px 0;
  font-family: var(--body); font-size: 1rem; color: var(--ink);
  background: #0a181d; border: 1px solid #2b4d56;
  caret-color: var(--cyan); letter-spacing: .06em; text-transform: uppercase;
}
.field::placeholder { color: #4c6b70; text-transform: none; letter-spacing: .02em; }
.field:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 14px rgba(69,227,210,.3); background: #0c1f25; }

.btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 20px 13px 30px;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #1b3a44, #10262e);
  box-shadow: inset 0 0 0 1px var(--gold-deep), inset 0 0 0 2px #0d2027, 0 3px 0 #061014;
  transition: color 120ms ease-out, box-shadow 120ms ease-out, transform 90ms ease-out;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn::before {
  content: "\25B6"; position: absolute; left: 12px; color: var(--cyan);
  opacity: 0; transform: translateX(-4px);
  transition: opacity 120ms ease-out, transform 120ms ease-out;
  font-size: .7em;
}
.btn:hover, .btn:focus-visible { color: #fff; box-shadow: inset 0 0 0 1px var(--gold), inset 0 0 0 2px #0d2027, 0 3px 0 #061014, 0 0 18px rgba(242,199,81,.3); }
.btn:hover::before, .btn:focus-visible::before { opacity: 1; transform: translateX(0); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px var(--gold-deep), inset 0 0 0 2px #0d2027; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; padding-left: 20px; }
.btn-cyan { color: var(--cyan); }
.btn-cyan:hover, .btn-cyan:focus-visible { color: #eafffb; box-shadow: inset 0 0 0 1px var(--cyan-deep), inset 0 0 0 2px #0d2027, 0 0 18px rgba(69,227,210,.3); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- class badge (shown when player recognized) ---- */
.class-badge {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-top: 12px;
  background: #0b1c22; box-shadow: inset 0 0 0 1px var(--cyan-deep);
}
.class-badge .ico { font-size: 26px; line-height: 1; filter: drop-shadow(0 0 6px rgba(69,227,210,.5)); }
.class-badge .who { font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: var(--gold); letter-spacing: .05em; }
.class-badge .cls { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--cyan); }

/* ---- footer note ---- */
.footnote { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }

/* ---- utility spacing ---- */
.spread { flex: 1 1 auto; }
.stack-lg > * + * { margin-top: 22px; }
.stack > * + * { margin-top: 12px; }

/* ==========================================================================
   HUD topbar slot on inner pages
   ========================================================================== */
.hud-top #hud-slot { display: contents; }

/* ==========================================================================
   XP-HUD — fixed bottom (replaces dosimeter)
   ========================================================================== */
.xp-hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  padding: 8px 14px calc(8px + var(--safe-bot));
  background: linear-gradient(0deg, #081418 70%, transparent);
  pointer-events: none;
}
.xp-line { display: flex; justify-content: space-between; align-items: baseline; }
.xp-lvl { font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--gold); letter-spacing: .06em; }
.xp-num { font-size: 11px; letter-spacing: .12em; color: var(--cyan); }
.xp-bar {
  margin-top: 4px; height: 8px; background: #0a1c22;
  box-shadow: inset 0 0 0 1px var(--gold-deep); overflow: hidden;
}
.xp-fill {
  height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--gold) 0 6px, var(--gold-hi) 6px 8px);
  box-shadow: 0 0 10px rgba(242,199,81,.6);
  transition: width 700ms cubic-bezier(.2,.8,.2,1);
}
.xp-hud.is-max .xp-fill { background: repeating-linear-gradient(90deg, var(--cyan) 0 6px, #bafff6 6px 8px); box-shadow: 0 0 12px rgba(69,227,210,.7); }
.xp-hud.is-max .xp-lvl { color: var(--cyan); }
.xp-msg { margin-top: 4px; font-size: 10px; line-height: 1.35; color: var(--ink-dim); letter-spacing: .02em; }

/* keep page content clear of the fixed HUD */
.has-xphud { padding-bottom: 92px; }

/* ==========================================================================
   NPC dialogue box (prologue / final cutscene)
   ========================================================================== */
.dialogue {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start;
  background: linear-gradient(180deg, #143039, #0d2027);
  box-shadow: var(--panel-edge); padding: 16px 16px 18px;
}
.dlg-portrait {
  width: 64px; height: 64px; display: grid; place-items: center;
  font-size: 34px; background: #0a1c22; box-shadow: inset 0 0 0 1px var(--cyan-deep);
  filter: drop-shadow(0 0 8px rgba(69,227,210,.4));
}
.dlg-name { font-family: var(--display); font-weight: 700; color: var(--gold); font-size: 1.1rem; letter-spacing: .06em; }
.dlg-text {
  margin-top: 8px; min-height: 44vh; max-height: 56vh; overflow-y: auto;
  white-space: pre-wrap; font-size: 14px; line-height: 1.6; color: var(--ink);
}
.tw-line { min-height: 1.1em; }
.tw-line:empty::after, .tw-line { }
.dlg-text::-webkit-scrollbar { width: 6px; }
.dlg-text::-webkit-scrollbar-thumb { background: var(--cyan-deep); }

/* ==========================================================================
   LEVEL UP — the motion peak
   ========================================================================== */
.levelup {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: radial-gradient(circle at center, rgba(8,20,24,.4), rgba(7,17,21,.86));
  opacity: 0; transition: opacity 300ms ease-out; pointer-events: none;
}
.levelup.show { opacity: 1; }
.levelup-inner { position: relative; display: grid; place-items: center; }
.lu-burst {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-hi);
  box-shadow: 0 0 0 0 rgba(242,199,81,.7);
}
.levelup.show .lu-burst { animation: lu-ring 900ms ease-out forwards; }
@keyframes lu-ring {
  0%   { box-shadow: 0 0 0 0 rgba(242,199,81,.7), 0 0 0 0 rgba(69,227,210,.5); }
  100% { box-shadow: 0 0 0 46vmin rgba(242,199,81,0), 0 0 0 30vmin rgba(69,227,210,0); }
}
.lu-text {
  font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 11vw, 3.6rem);
  color: var(--gold-hi); letter-spacing: .06em; text-transform: uppercase;
  text-shadow: 0 0 18px rgba(242,199,81,.6), 0 3px 0 var(--gold-deep);
  transform: scale(.95); opacity: 0;
}
.levelup.show .lu-text { animation: lu-pop 600ms cubic-bezier(.2,.9,.2,1.2) 120ms forwards; }
@keyframes lu-pop { to { transform: scale(1); opacity: 1; } }

/* ==========================================================================
   World map
   ========================================================================== */
.map-wrap { position: relative; }
.map-svg { width: 100%; height: auto; display: block; }
.map-node { cursor: pointer; }
.map-node[data-locked="1"] { cursor: not-allowed; }
.node-dot { transition: transform 200ms ease-out; transform-box: fill-box; transform-origin: center; }
.map-node.is-active .node-dot { animation: node-pulse 1.7s ease-in-out infinite; }
@keyframes node-pulse { 0%,100% { filter: drop-shadow(0 0 3px var(--gold)); } 50% { filter: drop-shadow(0 0 10px var(--gold)); } }
.map-legend { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; }
.map-legend div { display: flex; align-items: center; gap: 7px; }
.map-legend .sw { width: 11px; height: 11px; box-shadow: 0 0 5px currentColor; }
.m-active { background: var(--gold); color: var(--gold); }
.m-done   { background: var(--cyan); color: var(--cyan); }
.m-lock   { background: #3a565d; color: #3a565d; }
.m-boss   { background: var(--coral); color: var(--coral); }

/* ==========================================================================
   Quest page
   ========================================================================== */
.quest-place { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); }
.quest-story {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.62; color: var(--ink-soft);
  background: #0b1c22; box-shadow: inset 0 0 0 1px #23424c; padding: 13px 14px; margin: 12px 0;
}
.quest-task { font-size: 14px; line-height: 1.55; color: var(--ink); margin: 10px 0; }
.quest-task b, .quest-task strong { color: var(--gold); }

.feedback { margin-top: 14px; padding: 12px 14px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; box-shadow: inset 0 0 0 1px currentColor; }
.feedback.ok   { color: var(--cyan);  background: rgba(69,227,210,.06); }
.feedback.bad  { color: var(--danger);background: rgba(255,107,82,.07); }
.feedback.info { color: var(--gold);  background: rgba(242,199,81,.06); }
.hint { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--ink-dim); }

/* ---- interactive: morse ---- */
.morse-play { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.morse-sig { display: flex; gap: 6px; align-items: center; padding: 10px 12px; background: #0a1c22; box-shadow: inset 0 0 0 1px #23424c; }
.morse-sym { width: 12px; height: 12px; border-radius: 50%; background: #315860; box-shadow: inset 0 0 0 1px var(--cyan-deep); }
.morse-sym.dash { width: 28px; border-radius: 6px; }
.morse-sym.on { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.morse-gap { width: 8px; }

/* ---- interactive: rebus ---- */
.rebus { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 10px 0 14px; flex-wrap: wrap; }
.rebus .r-syl { font-family: var(--display); font-size: 2.4rem; color: var(--gold); }
.rebus .r-plus { color: var(--ink-dim); font-size: 1.6rem; }
.rebus .r-box { position: relative; padding: 14px 16px; box-shadow: inset 0 0 0 2px var(--cyan-deep); background: #0a1c22; }
.rebus .r-box span { font-family: var(--display); font-size: 1.6rem; color: var(--cyan); letter-spacing: .3em; }
.rebus .r-box::after { content: "?"; position: absolute; top: -10px; right: -8px; font-family: var(--display); color: var(--gold); font-size: 1.2rem; }

/* ---- interactive: caesar wheel ---- */
.cipher { margin: 10px 0 14px; }
.cipher-word { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cwheel { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cwheel .enc { font-family: var(--display); font-size: 1.5rem; color: var(--ink-dim); }
.cwheel .dec { font-family: var(--display); font-size: 2rem; color: var(--cyan); text-shadow: 0 0 10px rgba(69,227,210,.4); }
.cwheel .knob { display: flex; gap: 4px; margin-top: 2px; }
.cwheel .knob button { width: 26px; height: 22px; font-family: var(--display); color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-deep); }
.cwheel .knob button:active { transform: translateY(1px); }
.cipher-shift { text-align: center; font-size: 11px; color: var(--ink-dim); letter-spacing: .12em; margin-top: 8px; }

/* ---- interactive: grid ---- */
.grid-wrap { display: grid; place-items: center; margin: 10px 0 14px; }
.gridtbl { border-collapse: collapse; }
.gridtbl td { width: 40px; height: 40px; box-shadow: inset 0 0 0 1px #2b4d56; text-align: center; cursor: pointer; position: relative; }
.gridtbl td .mk { color: var(--coral); font-size: 1.2rem; }
.gridtbl td.sel { background: rgba(242,199,81,.14); }
.gridtbl td.cross { background: rgba(69,227,210,.16); box-shadow: inset 0 0 0 1px var(--cyan); }
.gridtbl .hdr { color: var(--ink-dim); font-size: 12px; cursor: default; box-shadow: none; }

/* ---- interactive: craft photo ---- */
.craft-photo { margin: 10px 0 14px; }
.craft-drop {
  display: grid; place-items: center; gap: 8px; padding: 22px; text-align: center;
  background: #0a1c22; box-shadow: inset 0 0 0 1px var(--cyan-deep);
  color: var(--ink-soft); font-size: 12px; cursor: pointer;
}
.craft-drop .ico { font-size: 30px; }
.craft-preview { margin-top: 10px; box-shadow: inset 0 0 0 1px var(--gold-deep); }
.craft-preview img { width: 100%; display: block; }

/* ==========================================================================
   Character card (final)
   ========================================================================== */
.charcard { background: linear-gradient(180deg, #163842, #0c2027); box-shadow: var(--panel-edge); padding: 18px; }
.charcard .cc-top { display: flex; align-items: center; gap: 14px; border-bottom: 1px solid #24424b; padding-bottom: 12px; }
.charcard .cc-ico { font-size: 40px; filter: drop-shadow(0 0 8px rgba(69,227,210,.5)); }
.charcard .cc-name { font-family: var(--display); font-weight: 700; font-size: 1.7rem; color: var(--gold); line-height: 1; }
.charcard .cc-class { font-size: 12px; letter-spacing: .16em; color: var(--cyan); text-transform: uppercase; }
.cc-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #23424c; font-size: 13px; }
.cc-row .k { color: var(--ink-dim); letter-spacing: .08em; }
.cc-row .v { color: var(--gold); text-align: right; }
.cc-badges { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 11px; }
.cc-badges span { padding: 5px 8px; box-shadow: inset 0 0 0 1px #23424c; color: var(--ink-dim); }
.cc-badges span.on { color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan-deep); }
.cc-seal { margin-top: 14px; text-align: center; font-size: 10px; letter-spacing: .2em; color: var(--ink-dim); }

/* ==========================================================================
   reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .press-start { animation: none; opacity: 1; }
  .map-node.is-active .node-dot { animation: none; }
  .levelup.show .lu-burst, .levelup.show .lu-text { animation: none; }
  .levelup.show .lu-text { opacity: 1; transform: none; }
  .xp-fill { transition: none; }
}

/* small screens */
@media (max-width: 380px) {
  .gridtbl td { width: 34px; height: 34px; }
  .dlg-text { min-height: 40vh; }
}

/* ==========================================================================
   PRINT — character card as a clean light sheet
   ========================================================================== */
@media print {
  .waterbed, .screen-sheen, .xp-hud, .hud-top, .btn-row, .btn { display: none !important; }
  html, body { background: #fff !important; color: #14110a !important; }
  body { padding: 0; }
  .stage { max-width: 100%; padding: 0; }
  h2 { color: #6b4e12 !important; text-shadow: none !important; }
  .charcard {
    background: #fff !important; color: #14110a !important;
    box-shadow: none !important; border: 3px double #6b4e12; padding: 14mm;
  }
  .charcard .cc-name, h2 { color: #6b4e12 !important; }
  .charcard .cc-class, .cc-row .v { color: #14110a !important; }
  .cc-row { border-bottom: 1px solid #bbb; }
  .cc-row .k { color: #555 !important; }
  .cc-badges span { box-shadow: inset 0 0 0 1px #999 !important; color: #555 !important; }
  .cc-badges span.on { color: #14110a !important; box-shadow: inset 0 0 0 1px #6b4e12 !important; }
  .cc-seal { color: #6b4e12 !important; border-top: 1px solid #6b4e12; padding-top: 3mm; margin-top: 8mm; }
  @page { size: A5; margin: 12mm; }
}
