/* ===== Verity-Boy: Minecraft-стиль ===== */
:root {
  --font: 'Press Start 2P', 'Courier New', monospace;
  --panel: #c6c6c6;
  --panel-dark: #555;
  --panel-light: #fff;
  --btn: #7a7a7a;
  --btn-hi: #9a9a9a;
  --green: #54e01f;
  --red: #e0422f;
  --gold: #ffd21f;
  --text-dark: #202020;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #87ceeb; font-family: var(--font); color: #fff; user-select: none; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: none; }
.hidden { display: none !important; }

/* ----- панели и кнопки ----- */
.mc-panel {
  background: var(--panel); color: var(--text-dark);
  border: 4px solid; border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
  box-shadow: 0 0 0 4px #000, 0 12px 40px rgba(0,0,0,.45);
}
.mc-btn {
  font: 12px var(--font); color: #fff; text-shadow: 2px 2px #3a3a3a;
  background: var(--btn); padding: 14px 18px; cursor: pointer; width: 100%;
  border: 3px solid; border-color: #bcbcbc #3a3a3a #3a3a3a #bcbcbc; outline: 2px solid #000;
}
.mc-btn:hover:not(:disabled) { background: #6f7fb5; }
.mc-btn:active:not(:disabled) { border-color: #3a3a3a #bcbcbc #bcbcbc #3a3a3a; }
.mc-btn:disabled { opacity: .45; cursor: not-allowed; }
.mc-btn.big { padding: 18px; font-size: 14px; }
.mc-btn.small { width: auto; padding: 10px 14px; font-size: 10px; }
.mc-btn.toggle.active { background: #3f8f2a; }
.mc-input {
  font: 14px var(--font); width: 100%; padding: 12px; background: #000; color: #fff;
  border: 3px solid; border-color: #3a3a3a #bcbcbc #bcbcbc #3a3a3a; outline: none; user-select: text;
}
.mc-input:focus { border-color: #3a3a3a #fff #fff #3a3a3a; }
.mc-input.bad { background: #4a0e0e; }
.mc-range { width: 100%; accent-color: #3f8f2a; }

/* ----- экраны меню ----- */
#screens { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.28); overflow: auto; padding: 16px; }
#screens > * { pointer-events: auto; }
#screens.hidden { display: none; }
.screen { width: min(460px, 94vw); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.screen.wide { width: min(640px, 96vw); }
.screen-title { margin: 0 0 4px; font-size: 16px; text-align: center; color: var(--text-dark); }
.logo { margin: 0; text-align: center; font-size: 26px; color: var(--gold); text-shadow: 3px 3px #7a5a00, 6px 6px #2b1f00; }
.subtitle { margin: 0; text-align: center; font-size: 9px; color: #4a4a4a; line-height: 1.6; }
.logo-faces { display: flex; justify-content: center; gap: 8px; }
.hint { font-size: 9px; line-height: 1.7; color: #3a3a3a; margin: 0; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 10px; color: var(--text-dark); }
.field-value { color: #2b6a12; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .mc-btn { flex: 1; }
.error { margin: 0; min-height: 14px; font-size: 9px; color: #b01818; }
.net-status { margin: 0; text-align: center; font-size: 8px; }
.net-status.on { color: #1f7a10; }
.net-status.off { color: #a02020; }
.code-box { font-size: 28px; letter-spacing: 4px; text-align: center; padding: 18px; background: #000; color: var(--green); border: 3px solid #3a3a3a; user-select: text; }
.sub-title { margin: 6px 0 0; font-size: 10px; color: var(--text-dark); }

/* ----- таблицы ----- */
.stat-table { width: 100%; border-collapse: collapse; font-size: 10px; color: var(--text-dark); }
.stat-table td, .stat-table th { padding: 8px 6px; border-bottom: 2px solid #9a9a9a; text-align: left; }
.stat-table td.v { text-align: right; color: #1f5a10; }
.stat-table th { font-size: 9px; color: #444; }
.stat-table.lb td, .stat-table.lb th { text-align: center; }
.stat-table tr.me { background: rgba(84,224,31,.3); }
.per-verity { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.pv-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 9px; color: var(--text-dark); }
.rating { font-size: 12px; text-align: center; color: #1f5a10; margin: 0; }
.win .screen-title { color: #1f7a10; } .lose .screen-title { color: #a02020; }

/* ----- соло ----- */
.solo { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--text-dark); }
.solo-bar { display: flex; gap: 16px; font-size: 10px; flex-wrap: wrap; justify-content: center; }
.solo-lives { color: #c01818; }
.solo-stage { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.solo-name { font-size: 20px; text-align: center; color: #1b3a8a; }
.solo-label { min-height: 16px; font-size: 12px; }
.solo-label.ok { color: #1f7a10; } .solo-label.bad { color: #b01818; }
.solo-options.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.solo-options.faces { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.solo-face-btn { background: var(--btn); border: 3px solid; border-color: #bcbcbc #3a3a3a #3a3a3a #bcbcbc; outline: 2px solid #000; padding: 8px; cursor: pointer; }
.solo-face-btn:hover:not(:disabled), .solo-opt:hover:not(:disabled) { background: #6f7fb5; }
.solo-opt { font-size: 10px; }
.right { background: #2f9a22 !important; } .wrong { background: #b02a1c !important; }
.solo-over { font-size: 18px; margin: 0; } .solo-final { font-size: 10px; }
.solo-record { color: #b07a00; font-size: 12px; } .solo-prev { font-size: 10px; }

/* ----- HUD ----- */
#hud > * { pointer-events: none; }
.hud-top { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); padding: 8px 14px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 96vw; font-size: 10px; }
.hud-status[data-tone="turn"] { color: #1f7a10; } .hud-status[data-tone="wait"] { color: #7a5a00; }
.timers .timer, .hud-timers .timer { padding: 3px 6px; margin-right: 6px; }
.timer.active { background: #3f8f2a; color: #fff; } .timer.low { color: #c01818; }
.crosshair { position: fixed; top: 50%; left: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: #fff; mix-blend-mode: difference; }
.crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; } .crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; } .ability-btn:disabled { opacity: .4; cursor: not-allowed; } .ability-btn:hover:not(:disabled) { background: #3f8f2a; }

/* ----- хотбар и инвентарь ----- */
.hotbar { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,.55); border: 3px solid #222; pointer-events: auto; }
.slot { position: relative; width: 48px; height: 48px; background: #8b8b8b; border: 3px solid; border-color: #373737 #fff #fff #373737; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot canvas { width: 38px; height: 38px; pointer-events: none; }
.slot-selected { outline: 4px solid #fff; z-index: 1; box-shadow: 0 0 0 2px #000; }
.slot-dim canvas { opacity: .25; filter: grayscale(1); }
.slot-key { position: absolute; top: -1px; left: 2px; font-size: 7px; color: #fff; text-shadow: 1px 1px #000; }
.slot-count { position: absolute; bottom: -2px; right: 1px; font-size: 9px; color: #fff; text-shadow: 2px 2px #000; pointer-events: none; }
.inv-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); pointer-events: auto; }
.inv-window { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.inv-title { margin: 0; font-size: 12px; color: #404040; }
.inv-hint { margin: 0; font-size: 7px; line-height: 1.6; color: #555; max-width: 440px; }
.craft { display: flex; align-items: center; gap: 14px; }
.craft-grid { display: grid; grid-template-columns: 48px 48px; gap: 2px; }
.craft-arrow { font-size: 22px; color: #555; }
.craft-nav { display: flex; align-items: center; gap: 8px; font-size: 9px; color: #333; }
.slot-grid { display: grid; grid-template-columns: repeat(9, 48px); gap: 2px; }
.slot-sep { height: 4px; }
.cursor-item { position: fixed; z-index: 100; width: 40px; height: 40px; pointer-events: none; }
.cursor-item canvas { width: 40px; height: 40px; }

/* ----- чат и тосты ----- */
.chat { position: fixed; left: 12px; bottom: 100px; width: min(380px, 60vw); pointer-events: none; }
.chat-log { max-height: 140px; overflow: hidden; font-size: 8px; line-height: 1.6; opacity: 0; transition: opacity .3s; }
.chat.recent .chat-log, .chat.open .chat-log { opacity: 1; }
.chat-line { background: rgba(0,0,0,.55); padding: 3px 6px; margin-top: 2px; word-break: break-word; }
.chat-line.sys { color: #ffe36a; }
.chat-input { display: none; font-size: 10px; padding: 8px; margin-top: 4px; pointer-events: auto; }
.chat.open .chat-input { display: block; }
.toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 50; pointer-events: none; }
.toast { background: rgba(0,0,0,.78); border: 2px solid #888; padding: 8px 12px; font-size: 10px; text-align: center; transition: opacity .5s; max-width: 92vw; }
.toast.good { border-color: var(--green); } .toast.bad { border-color: var(--red); } .toast.out { opacity: 0; }

@media (max-width: 720px) {
  .slot, .slot-grid { --s: 38px; }
  .slot { width: 38px; height: 38px; } .slot canvas { width: 30px; height: 30px; }
  .slot-grid { grid-template-columns: repeat(9, 38px); }
  .logo { font-size: 18px; }
}


/* ================= v3: подсказки, готовность, способности ================= */
html, body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game-canvas { touch-action: none; }
.hud-top { padding: 8px 16px; gap: 6px 18px; }
.hud-status { font-size: 13px; line-height: 1.4; max-width: 560px; text-align: center; }
.hud-status[data-tone="turn"] { color: #1f7a10; } .hud-status[data-tone="wait"] { color: #7a5a00; } .hud-status[data-tone="info"] { color: #20304a; }
.hud-score { font-size: 10px; }

.hud-hint { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); max-width: min(760px, 94vw); padding: 8px 14px;
  background: rgba(0,0,0,.62); border: 2px solid #777; font-size: 10px; line-height: 1.6; text-align: center; pointer-events: none; }
.hud-hint.hidden { display: none; }
.click-hint { position: fixed; top: 58%; left: 50%; transform: translateX(-50%); padding: 12px 18px; background: rgba(0,0,0,.72);
  border: 3px solid var(--gold); font-size: 12px; text-align: center; animation: pulse-border 1.2s infinite; pointer-events: none; }
@keyframes pulse-border { 50% { border-color: #fff; } }

.menu-btn { position: fixed; top: 10px; right: 10px; width: 44px; height: 44px; font: 20px var(--font); color: #fff; background: rgba(30,30,30,.78);
  border: 3px solid #999; cursor: pointer; pointer-events: auto; z-index: 5; }
.menu-btn:hover { background: #3f8f2a; }

/* «Готов»: три состояния — можно нажать (пульсирует) / подтверждено (зелёная) */
.ready-btn { position: fixed; bottom: 118px; left: 50%; transform: translateX(-50%); width: auto; min-width: 240px; pointer-events: auto; z-index: 4; }
.ready-btn.pulse { background: #4a9a2a; animation: ready-pulse 1s infinite; }
.ready-btn.confirmed { background: #1f8f12; border-color: #9dff7a #0e4a08 #0e4a08 #9dff7a; opacity: 1; cursor: default; box-shadow: 0 0 0 3px #54e01f, 0 0 24px #54e01f; }
@keyframes ready-pulse { 50% { transform: translateX(-50%) scale(1.06); box-shadow: 0 0 18px #9dff7a; } }

/* способности */
.abilities { position: fixed; right: 10px; bottom: 90px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 178px; z-index: 4; }
.ability-btn { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 8px; font: 10px var(--font); color: #fff; text-align: left;
  background: rgba(30,30,30,.86); border: 3px solid #666; padding: 10px; cursor: pointer; }
.ability-btn .ab-icon { font-size: 18px; } .ability-btn .ab-name { flex: 1; line-height: 1.3; }
.ability-btn .ab-key { color: var(--gold); font-size: 9px; border: 2px solid #777; padding: 2px 5px; }
.ability-btn:disabled { opacity: .45; cursor: not-allowed; }
.ability-btn.charged { border-color: var(--green); background: rgba(40,90,25,.9); animation: ready-pulse2 1.2s infinite; }
@keyframes ready-pulse2 { 50% { box-shadow: 0 0 14px var(--green); } }
.ability-btn.charged:hover { background: #3f8f2a; }
.charge { font-size: 10px; color: #bbb; text-align: center; text-shadow: 2px 2px #000; }
.charge.full { color: var(--gold); }

/* кнопки-подсказки клавиш скрываем на телефоне */
.is-touch .ab-key, .is-touch .crosshair { display: none; }
.is-touch .hud-hint { bottom: 64px; font-size: 9px; }

/* ================= пауза ================= */
.pause-root { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); pointer-events: auto !important; z-index: 20; overflow: auto; padding: 16px; }
.pause-root.hidden { display: none; }
.pause-panel { max-height: 94vh; overflow: auto; }
.mc-btn.danger { background: #a02a1c; border-color: #e68a7c #4a0e08 #4a0e08 #e68a7c; }
.mc-btn.danger:hover:not(:disabled) { background: #c23a28; }
.help-table td.key { color: #7a3a00; white-space: nowrap; width: 38%; }

/* ================= карты ================= */
.biome-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.biome-card { background: #b0b0b0; border: 3px solid; border-color: #fff #555 #555 #fff; padding: 8px; display: flex; flex-direction: column; gap: 6px; color: var(--text-dark); }
.biome-card.active { outline: 4px solid var(--green); }
.biome-swatch { position: relative; height: 64px; border: 2px solid #000; }
.biome-lock { position: absolute; right: 4px; top: 4px; font-size: 16px; }
.biome-name { font-size: 11px; } .biome-hint { font-size: 7px; line-height: 1.5; color: #444; min-height: 22px; }
.biome-card.locked .biome-swatch { filter: grayscale(.55) brightness(.8); }
.mc-btn.reward { background: #9a7a1a; border-color: #ffe37a #5a4300 #5a4300 #ffe37a; }
.mc-btn.reward:hover:not(:disabled) { background: #b8921f; }
.biome-card .mc-btn { width: 100%; font-size: 8px; padding: 8px 4px; }

/* имитация рекламы (режим разработки) */
.fake-ad { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.85); pointer-events: auto; }
.fake-ad-box { padding: 24px; width: min(380px, 90vw); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.fake-ad-box h3 { margin: 0; font-size: 14px; } .fake-ad-box p { margin: 0; font-size: 9px; line-height: 1.7; }

/* ================= сенсорное управление ================= */
.touch-mount { position: fixed; inset: 0; pointer-events: none; }
.touch-ui { position: absolute; inset: 0; pointer-events: none; }
.touch-ui.hidden { display: none; }
.joy { position: absolute; left: 22px; bottom: 120px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.16); border: 3px solid rgba(255,255,255,.55); pointer-events: auto; touch-action: none; }
.joy-thumb { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.6); border: 3px solid #fff; pointer-events: none; }
.touch-bar { position: absolute; right: 10px; top: 64px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.touch-btn { width: 48px; height: 48px; font-size: 22px; background: rgba(30,30,30,.78); border: 3px solid #999; color: #fff; pointer-events: auto; touch-action: manipulation; }
.touch-btn.on { background: #a02a1c; border-color: #ffb0a0; }
.touch-btn.hidden { display: none; }

@media (pointer: coarse), (max-width: 720px) {
  .abilities { width: 52px; bottom: 120px; right: 8px; }
  .ability-btn { padding: 8px 4px; justify-content: center; }
  .ability-btn .ab-name { display: none; } .ability-btn .ab-icon { font-size: 22px; }
  .charge { font-size: 8px; }
  .hud-status { font-size: 10px; } .hud-score { font-size: 8px; }
  .hotbar { bottom: 6px; padding: 3px; gap: 2px; }
  .slot { width: 36px; height: 36px; } .slot canvas { width: 28px; height: 28px; }
  .ready-btn { bottom: 108px; min-width: 200px; font-size: 11px; }
  .charge { text-shadow: 1px 1px #000; }
  .inv-window { padding: 10px; } .slot-grid { grid-template-columns: repeat(9, 36px); }
  .toasts { top: 112px; } .toast { font-size: 9px; }
  .chat { bottom: 88px; width: 70vw; left: 8px; }
  .chat-log { max-height: 90px; }
  .screen { padding: 16px; gap: 10px; } .logo { font-size: 18px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .joy { bottom: 60px; width: 100px; height: 100px; }
  .abilities { bottom: 70px; } .hud-hint { bottom: 54px; } .ready-btn { bottom: 90px; }
  .screen { max-height: 96vh; overflow: auto; }
}

/* Прямые дети #hud получают pointer-events:none от правила «#hud > *» (специфичнее класса),
   поэтому кликабельным кнопкам нужен !important — иначе мышь «проваливается» сквозь них. */
.menu-btn, .ready-btn { pointer-events: auto !important; }
.ready-btn:disabled { pointer-events: none !important; }
