:root { --bg: #0b0f0c; --bar: #151b17; --line: #24302a; --text: #cfe8d6; --dim: #7d9787; --accent: #4cf08a; --second: #ffd166; --error: #ff7b72;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; }
:root[data-theme="amber"] { --bg: #130d04; --bar: #20170a; --line: #3a2b12; --text: #ffdfa6; --dim: #b08f5c; --accent: #ffb000; --second: #fff0c2; }
:root[data-theme="white"] { --bg: #101113; --bar: #1b1d20; --line: #31343a; --text: #dfe2e6; --dim: #8b929c; --accent: #ffffff; --second: #8cc8ff; }
:root[data-theme="synth"] { --bg: #12041f; --bar: #200a35; --line: #3d1a5e; --text: #ecd9ff; --dim: #a483c4; --accent: #ff5fae; --second: #ffb347; }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
html, body { height: 100%; overflow: hidden; }
body { color: var(--text); font: 400 15px/1.65 var(--mono); }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; }
a { color: var(--second); text-underline-offset: 3px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.window { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 12px; padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); background: var(--bar); border-bottom: 1px solid var(--line); }
.bar h1, .bar h2 { flex: 1; font-size: 13px; font-weight: 400; color: var(--dim); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 7px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f56; }
.dots i:nth-child(2) { background: #ffbd2e; }
.dots i:nth-child(3) { background: #27c93f; }
.music, .close { flex: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 32px; padding: 2px 10px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; }
.music[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.screen { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left)); cursor: text; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.screen > * { max-width: 820px; margin-inline: auto; }
#out { overflow-wrap: break-word; }
#out p { margin: 4px 0; }
.entry { margin-top: 18px; animation: appear .25s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.banner { font-family: ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: clamp(7px, 2.5vw, 17px); line-height: 1.15; color: var(--accent); text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); margin-bottom: 10px; overflow: hidden; }
.sub { color: var(--dim); }
.ok { color: var(--accent); }
.dim { color: var(--dim); font-size: .9em; }
.error { color: var(--error); }
.title { margin: 8px 0 !important; color: var(--second); font-weight: 700; }
.echo span { color: var(--accent); }
.note { max-width: 62ch; }
.cat { color: var(--second); line-height: 1.25; margin: 6px 0 10px; }

.menu { display: grid; margin: 10px 0; max-width: 520px; }
.item { display: grid; grid-template-columns: 2ch 10ch 1fr; gap: 12px; align-items: baseline; min-height: 34px; padding: 4px 8px; text-align: left; border-radius: 4px; }
.item i { font-style: normal; color: var(--dim); white-space: pre; }
.item b { color: var(--accent); }
.menu-options .item { grid-template-columns: 2ch 1fr; }
.item:hover, .item:focus-visible { background: var(--accent); color: var(--bg); }
.item:hover *, .item:focus-visible * { color: var(--bg); }
.run { color: var(--accent); text-decoration: underline dashed; text-underline-offset: 4px; }

.projects { list-style: none; counter-reset: p; }
.projects li { counter-increment: p; position: relative; padding: 6px 0 6px 5ch; }
.projects li::before { content: "[" counter(p) "]"; position: absolute; left: 0; color: var(--dim); }
.projects span { display: block; color: var(--dim); }
.contacts { list-style: none; }
.contacts li { display: grid; grid-template-columns: 14ch minmax(0, 1fr); gap: 10px; padding: 4px 0; }
.contacts span { color: var(--dim); }

.message { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); margin: 8px 0; padding: 12px 14px; border: 1px dashed var(--accent); border-radius: 6px; user-select: all; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.action { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 16px; background: var(--accent); color: var(--bg); font-weight: 700; text-decoration: none; border-radius: 6px; }

.line { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; margin-top: 16px; }
.line label { color: var(--accent); white-space: nowrap; }
.line input { flex: 1; min-width: 12ch; min-height: 36px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; caret-color: var(--accent); outline: 0; }
.line input:focus { border-bottom-color: var(--accent); }
.line input::placeholder { color: var(--dim); opacity: .7; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); background: var(--bar); border-top: 1px solid var(--line); scrollbar-width: none; }
.chip { flex: none; min-height: 38px; padding: 4px 14px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; }
.chip:first-child { margin-left: auto; }
.chip:last-child { margin-right: auto; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* лёгкие строки развёртки, как на старом мониторе */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 20; background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .14) 2px 3px); }

/* ---------- игра ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; overflow-y: auto; padding: 10px; background: rgba(0, 0, 0, .82); }
.game { --board: min(460px, 100vw - 24px, 100dvh - 210px); width: calc(var(--board) + 2px); background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; text-align: center; }
.game .bar h2 { text-align: left; }
.hud { display: flex; justify-content: space-between; padding: 6px 14px; font-size: 13px; color: var(--dim); }
.hud b { color: var(--accent); }
.field { position: relative; width: var(--board); height: var(--board); touch-action: none; }
.field canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .78); font-weight: 700; font-size: 18px; color: var(--accent); cursor: pointer; }
.overlay.hidden { display: none; }
.overlay small { color: var(--text); font-weight: 400; font-size: 13px; }
.help { padding: 8px 10px; font-size: 11px; color: var(--dim); }
.help-touch, .pad { display: none; }
.touch .help-pc { display: none; }
.touch .help-touch { display: block; }
.touch .game { --board: min(460px, 100vw - 24px, 100dvh - 280px); }
.touch .pad { display: grid; grid-template-areas: ". up ." "left down right"; grid-template-columns: repeat(3, 66px); grid-auto-rows: 52px; gap: 6px; justify-content: center; padding-bottom: 12px; }
.pad button { border: 1px solid var(--line); border-radius: 8px; background: var(--bar); font-size: 18px; user-select: none; -webkit-user-select: none; }
.pad button:active { background: var(--accent); color: var(--bg); }
.b-up { grid-area: up; } .b-left { grid-area: left; } .b-down { grid-area: down; } .b-right { grid-area: right; }

@media (max-width: 600px) {
  body { font-size: 14px; }
  .banner { font-size: calc((100vw - 34px) / 22); }
  .item { gap: 10px; min-height: 40px; align-items: center; padding-inline: 4px; }
  .line input { font-size: 16px; } /* меньше 16px — iPhone увеличивает страницу */
  .contacts li { grid-template-columns: 1fr; gap: 0; }
  .chip:first-child { margin-left: 0; }
}
/* телефон боком: поле слева, управление справа */
@media (orientation: landscape) and (max-height: 520px) {
  .touch .game { --board: min(100dvh - 96px, 55vw); width: auto; display: grid; grid-template-columns: var(--board) 220px; grid-template-rows: auto auto 1fr auto; }
  .touch .game .bar { grid-column: 1 / -1; }
  .touch .field { grid-column: 1; grid-row: 2 / 5; }
  .touch .hud { grid-column: 2; grid-row: 2; }
  .touch .help { grid-column: 2; grid-row: 3; }
  .touch .pad { grid-column: 2; grid-row: 4; }
}
@media (prefers-reduced-motion: reduce) { .entry { animation: none; } }
