/* ============ KVIBE ARCADE — палитра МЕНЮ/АВТОРА: Dynamite Red, Jack and Coke,
   Vampiric Council, Mimolette Orange, Artichoke Heart. Внутри игр действуют
   собственные палитры (см. JS игр) — отсюда не применяются. ============ */
:root {
  --dynamite: #e63946;        /* Dynamite Red */
  --jack: #2b1a12;            /* Jack and Coke */
  --vampiric: #521b3d;        /* Vampiric Council */
  --mimolette: #f79233;       /* Mimolette Orange */
  --artichoke: #93b56b;       /* Artichoke Heart */
  --paper: #f7f2e6;
  --ink: #241713;
  --shadow: 0 10px 30px rgba(43, 26, 18, .35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(147,181,107,.25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(247,146,51,.28), transparent 60%),
    linear-gradient(160deg, #fff8ec 0%, #ffe9d2 45%, #ffd7c2 100%);
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
code { background: rgba(82,27,61,.15); padding: 1px 6px; border-radius: 6px; }

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- ЭКРАН АВТОРИЗАЦИИ ---------- */
#screen-auth { align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: min(430px, 100%); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: var(--shadow); padding: 26px 26px 20px;
}
.logo {
  font-weight: 900; font-size: 34px; letter-spacing: 2px; text-align: center;
  color: var(--dynamite); text-shadow: 3px 3px 0 var(--ink);
}
.logo span { color: var(--mimolette); }
.logo.small { font-size: 20px; text-shadow: 2px 2px 0 var(--ink); }
.tagline { text-align: center; color: #7a5c4b; margin: 6px 0 16px; font-size: 14px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; padding: 10px; border-radius: 12px; border: 2px solid var(--ink);
  background: #fff; font-weight: 700;
}
.auth-tab.active { background: var(--vampiric); color: #fff; }
.auth-form { display: none; flex-direction: column; gap: 10px; }
.auth-form.active { display: flex; }
.auth-form label { font-size: 13px; font-weight: 700; color: var(--jack); display: flex; flex-direction: column; gap: 4px; }
.auth-form input {
  padding: 11px 12px; border-radius: 12px; border: 2px solid var(--ink);
  font-size: 15px; background: #fff; outline-color: var(--mimolette);
}
.form-err { color: var(--dynamite); font-weight: 700; font-size: 13px; min-height: 16px; margin: 0; }
.btn-primary {
  padding: 12px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--dynamite); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 0 var(--ink); transition: transform .1s;
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.hint { font-size: 12px; color: #8b6a55; margin: 2px 0 0; }
.admin-hint { text-align: center; font-size: 12px; color: #9b7f6d; margin: 14px 0 0; }
#quick-accounts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.quick-acc {
  font-size: 12px; padding: 5px 9px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--artichoke);
}

/* ---------- ТОПБАР МЕНЮ ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--jack);
  border-bottom: 3px solid var(--ink);
  color: var(--paper); position: sticky; top: 0; z-index: 20;
}
.topnav, .userbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topnav { flex: 1; justify-content: center; }
.nav-btn {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--paper);
  background: transparent; color: var(--paper); font-weight: 700;
}
.nav-btn:hover { background: rgba(255,255,255,.12); }
.nav-btn.active { background: var(--mimolette); color: var(--ink); border-color: var(--ink); }
#score-pill {
  background: var(--vampiric); border: 2px solid var(--paper); color: var(--mimolette);
  padding: 7px 12px; border-radius: 999px; font-weight: 800;
}
#account-switch {
  padding: 7px 10px; border-radius: 999px; border: 2px solid var(--paper);
  background: var(--artichoke); font-weight: 700; max-width: 170px;
}

/* ---------- ВИДЫ ---------- */
.view { display: none; padding: 22px 18px 44px; }
.view.active { display: block; }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.menu-head h1 { margin: 0 0 16px; font-size: 28px; color: var(--jack); }
#game-search {
  padding: 10px 14px; border-radius: 999px; border: 2px solid var(--ink);
  font-size: 15px; min-width: 220px; background: var(--paper);
}
.count-pill { background: var(--dynamite); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 800; border: 2px solid var(--ink); }

/* ---------- СЕТКА ИГР ---------- */
.game-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.game-card {
  position: relative; text-align: left; padding: 14px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink); overflow: hidden;
  transition: transform .12s;
}
.game-card:hover { transform: translateY(-4px) rotate(-.4deg); }
.game-card .emoji { font-size: 42px; display: block; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.2)); }
.game-card h3 { margin: 8px 0 4px; font-size: 17px; color: var(--jack); }
.game-card p { margin: 0; font-size: 12px; color: #8b6a55; line-height: 1.35; }
.game-card .tag {
  position: absolute; top: 10px; right: 10px; font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--artichoke); text-transform: uppercase;
}
.game-card .best { margin-top: 8px; font-size: 12px; font-weight: 800; color: var(--dynamite); }

/* ---------- ИСТОРИЯ / АДМИНКА ---------- */
.history-list, .admin-list { display: flex; flex-direction: column; gap: 8px; max-width: 860px; }
.hist-row, .admin-row {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 14px;
  padding: 10px 14px; flex-wrap: wrap;
}
.hist-main { font-weight: 700; color: var(--jack); }
.hist-sub { font-size: 12px; color: #8b6a55; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; border: 2px solid var(--ink); }
.badge.game { background: var(--mimolette); }
.badge.auth { background: var(--artichoke); }
.badge.admin { background: var(--vampiric); color: #fff; }
.badge.danger { background: var(--dynamite); color: #fff; }
.admin-actions { display: flex; gap: 6px; }
.mini-btn {
  padding: 6px 11px; border-radius: 10px; border: 2px solid var(--ink);
  background: #fff; font-weight: 700; font-size: 12px;
}
.mini-btn.danger { background: var(--dynamite); color: #fff; }
.mini-btn.ok { background: var(--artichoke); }
.mini-btn.grant { background: var(--mimolette); }
.empty { color: #8b6a55; font-weight: 700; }

/* ---------- ЭКРАН ИГРЫ (общая оболочка; палитра игр своя) ---------- */
#screen-game { background: #10131a; }
.game-title { font-weight: 900; font-size: 18px; color: #fff; letter-spacing: 1px; }
.game-hud { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.hud-pill {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3);
  color: #fff; padding: 7px 14px; border-radius: 999px; font-weight: 800; min-width: 70px; text-align: center;
}
.stage-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 14px; min-height: 0;
}
#game-canvas {
  max-width: 100%; max-height: calc(100vh - 90px);
  background: #000; border: 3px solid #2a2f3a; border-radius: 14px;
  image-rendering: pixelated; display: block;
}
#game-canvas.dom-mode { display: none; }
.game-dom { position: absolute; inset: 60px 14px 14px; overflow: auto; color: #eee; }
.game-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.82); backdrop-filter: blur(3px); z-index: 10;
}
.overlay-card {
  background: #fff; color: #111; border: 3px solid #111; border-radius: 20px;
  padding: 26px 30px; text-align: center; max-width: 460px; box-shadow: var(--shadow);
}
.overlay-card h2 { margin: 0 0 8px; font-size: 26px; }
.overlay-card p { margin: 0 0 16px; color: #555; line-height: 1.45; white-space: pre-line; }
.overlay-card #overlay-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.overlay-card button {
  padding: 11px 20px; border-radius: 12px; border: 2px solid #111;
  font-weight: 800; font-size: 15px; background: var(--mimolette);
}
.overlay-card button.alt { background: #eee; }

@media (max-width: 640px) {
  .topbar { justify-content: space-between; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .menu-head h1 { font-size: 22px; }
}
