/* ====== DBZ BT3 Web — cascade layers: base < components < utilities ====== */
@layer base, components, utilities;

/* ================= BASE: kintamieji, temos, reset, elementai ================= */
@layer base {
  :root {
    /* „dbz" — šiltas gintarinis dark: oranžinė ne tik akcentas, bet ir paviršiai */
    --bg: #150c04;
    --bg-panel: #1e1206;
    --bg-raised: #2b1a09;
    --bg-input: #100803;
    --border: #4a2e0e;
    --text: #f4ecdf;
    --text-dim: #bfa88c;
    --accent: #ff8c00;
    --accent-hi: #ffb84d;
    --accent-2: #3d9bff;
    --danger: #ff5252;
    --radius: 10px;
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  }

  /* temos (html[data-theme]) — :root aukščiau yra „dbz" */
  [data-theme="dark"] {
    --bg: #000;
    --bg-panel: #0a0a0e;
    --bg-raised: #141419;
    --bg-input: #060608;
    --border: #232329;
    --text: #e6e6ec;
    --text-dim: #8b8b9a;
    --accent: #ff8c00;
    --accent-hi: #ffb84d;
    --accent-2: #58a6ff;
  }
  [data-theme="light"] {
    --bg: #eef0f5;
    --bg-panel: #ffffff;
    --bg-raised: #e4e7ee;
    --bg-input: #ffffff;
    --border: #c7ccd9;
    --text: #1c2130;
    --text-dim: #5a6378;
    --accent: #e06e00;
    --accent-hi: #b85300;
    --accent-2: #1565c0;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  [hidden] { display: none !important; }

  body {
    background: var(--bg);
    background-image:
      radial-gradient(ellipse 80% 45% at 50% -10%, rgba(255, 140, 0, 0.22), transparent),
      radial-gradient(ellipse 50% 35% at 85% 0%, rgba(255, 100, 0, 0.10), transparent),
      radial-gradient(ellipse 40% 30% at 10% 100%, rgba(255, 140, 0, 0.06), transparent);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
  }
  [data-theme="dark"] body { background-image: none; }
  [data-theme="light"] body {
    background-image:
      radial-gradient(ellipse 80% 40% at 50% -10%, rgba(224, 110, 0, 0.10), transparent),
      radial-gradient(ellipse 40% 30% at 90% 0%, rgba(21, 101, 192, 0.06), transparent);
  }

  .lang-select, select, input[type="text"], input[type="number"] {
    background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
    font-family: var(--font); font-size: 14px;
  }
  kbd {
    background: var(--bg-raised); border: 1px solid var(--border); border-bottom-width: 2px;
    border-radius: 5px; padding: 1px 7px; font-family: monospace; font-size: 12.5px;
  }

  /* a11y: fokuso ring'ai + reduced motion */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ================= COMPONENTS: blokai ir valdikliai ================= */
@layer components {

  /* header */
  .site-header {
    background: linear-gradient(180deg, #241505, #170d04);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 2px 14px rgba(255, 140, 0, 0.15);
    position: sticky; top: 0; z-index: 50;
  }
  [data-theme="dark"] .site-header { background: #050508; }
  [data-theme="light"] .site-header { background: linear-gradient(180deg, #ffffff, #eef0f5); }
  .header-inner {
    max-width: 1300px; margin: 0 auto; padding: 10px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
  }
  .logo {
    color: var(--text); text-decoration: none; font-weight: 800;
    font-size: 19px; letter-spacing: 0.5px;
  }
  .logo em { color: var(--accent); font-style: normal; }
  .logo-star { color: var(--accent); }
  .header-right { display: flex; align-items: center; gap: 10px; }
  .lang-label { color: var(--text-dim); font-size: 13px; }
  .badge-platform {
    color: var(--text-dim); font-size: 12px; border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 20px; white-space: nowrap;
  }

  /* layout */
  .layout {
    max-width: 1300px; margin: 0 auto; padding: 22px 20px 40px;
    display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px;
  }

  /* žaidimo stulpelis */
  .game-title {
    font-size: 30px; font-weight: 800;
    background: linear-gradient(90deg, var(--accent), var(--accent-hi), #ffe08a);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .game-sub { color: var(--text-dim); margin: 4px 0 10px; }
  .game-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
  .badge {
    background: var(--bg-raised); border: 1px solid var(--border);
    border-radius: 20px; padding: 4px 12px; font-size: 13px;
  }
  .badge-dim { color: var(--text-dim); }
  .pad-hint {
    background: rgba(61, 155, 255, 0.08); border: 1px solid rgba(61, 155, 255, 0.3);
    border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px;
  }
  [data-theme="light"] .pad-hint { background: rgba(21, 101, 192, 0.07); }

  .game-frame {
    position: relative; border: 2px solid var(--border); border-radius: var(--radius);
    overflow: hidden; background: #000; aspect-ratio: 4 / 3;
    box-shadow: 0 0 0 1px rgba(255,140,0,.12), 0 8px 32px rgba(0,0,0,.5);
  }
  .game-frame.ar-169 { aspect-ratio: 16 / 9; }
  .game-frame.ar-fill { aspect-ratio: auto; height: min(72vh, 760px); }
  .game-frame:fullscreen { border-radius: 0; aspect-ratio: auto; }
  #game-canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

  .game-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 14px;
    background: radial-gradient(ellipse at center, rgba(13,15,20,.75), rgba(13,15,20,.95));
    transition: opacity .3s;
  }
  .game-overlay.hidden { opacity: 0; pointer-events: none; }
  .overlay-stars { color: var(--accent); letter-spacing: 14px; font-size: 22px; }
  .overlay-status { color: var(--text-dim); font-size: 14px; }
  .overlay-note { color: var(--text-dim); font-size: 12.5px; }
  .key-entry { display: flex; gap: 8px; align-items: center; }
  .key-entry input { width: 150px; text-transform: uppercase; text-align: center; }
  .overlay-error { color: var(--danger) !important; font-weight: 600; }
  [data-theme="light"] .game-overlay { background: radial-gradient(ellipse at center, rgba(20,22,30,.72), rgba(20,22,30,.94)); color: #e8eaf2; }
  [data-theme="light"] .game-overlay .overlay-status, [data-theme="light"] .game-overlay .overlay-note { color: #aab; }

  .game-hud {
    position: absolute; top: 0; left: 0; right: 0; z-index: 5;
    display: flex; justify-content: space-between; padding: 8px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,.6), transparent);
    font-size: 12.5px; color: var(--text-dim); pointer-events: none;
  }
  .game-toolbar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

  /* mygtukai */
  .btn {
    background: var(--bg-raised); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 16px; font-size: 14px; font-family: var(--font);
    cursor: pointer; transition: border-color .15s, background .15s;
  }
  .btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg-panel); }
  .btn:disabled { opacity: .45; cursor: default; }
  .btn-primary {
    background: linear-gradient(180deg, var(--accent), #e07000);
    border-color: var(--accent-hi); color: #1a0e00; font-weight: 700;
    box-shadow: 0 2px 12px rgba(255, 140, 0, 0.35);
  }
  .btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); box-shadow: 0 4px 18px rgba(255, 140, 0, 0.45); }
  [data-theme="light"] .btn-primary { color: #fff; }
  .btn-big { font-size: 19px; padding: 12px 44px; letter-spacing: 1px; }
  .btn-sm { padding: 5px 12px; font-size: 13px; }
  .btn.active, .btn-group .btn.active, .lb-tabs .btn.active { border-color: var(--accent); color: var(--accent-hi); }
  .btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
  .btn-row { gap: 8px; }

  /* reklamos vieta */
  .ad-slot {
    margin: 20px 0; border: 1px dashed var(--border); border-radius: var(--radius);
    min-height: 90px; display: flex; align-items: center; justify-content: center;
    color: var(--text-dim); font-size: 13px; background: rgba(255,255,255,.015);
  }

  /* leaderboard */
  .leaderboard { margin-top: 8px; }
  .leaderboard h2 { font-size: 18px; margin-bottom: 10px; }
  .lb-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
  .lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .lb-table th, .lb-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
  .lb-table th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; text-transform: uppercase; }
  .lb-empty { color: var(--text-dim); text-align: center; padding: 20px !important; }
  .lb-note { color: var(--text-dim); font-size: 12.5px; margin-top: 8px; }

  /* panelė */
  .panel {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; align-self: start;
    position: sticky; top: 76px;
  }
  .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
  .tab {
    background: transparent; border: none; color: var(--text-dim);
    padding: 7px 11px; font-size: 13.5px; cursor: pointer;
    border-bottom: 2px solid transparent; font-family: var(--font);
  }
  .tab:hover { color: var(--text); }
  .tab.active, .tab[aria-selected="true"] { color: var(--accent-hi); border-bottom-color: var(--accent); font-weight: 600; }
  .tab[aria-selected="false"] { border-bottom-color: transparent; }
  .panel-note { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }

  .tab-page { display: none; }
  .tab-page.active { display: block; }
  .tab-page h3 { font-size: 14.5px; margin: 16px 0 8px; color: var(--accent-hi); }
  .tab-page h3:first-child { margin-top: 0; }

  .setting-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
  }
  .setting-row label { min-width: 110px; font-size: 14px; }
  .setting-val { color: var(--text-dim); font-size: 13px; }
  .setting-note { color: var(--text-dim); font-size: 12.5px; margin: 8px 0; }
  .setting-row input[type="range"] { flex: 1; accent-color: var(--accent); }
  .check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
  .check input { accent-color: var(--accent); }

  .warn-box {
    background: rgba(255, 140, 0, 0.07); border: 1px solid rgba(255, 140, 0, 0.3);
    border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
  }
  [data-theme="light"] .warn-box { background: rgba(224, 110, 0, 0.08); }

  /* chat */
  .chat-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
  .chat-log {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
    height: 200px; overflow-y: auto; padding: 8px 10px; font-size: 13.5px;
  }
  .chat-sys { color: var(--text-dim); font-style: italic; }
  .chat-msg { margin: 4px 0; }
  .chat-msg b { color: var(--accent-2); }
  .chat-input { display: flex; gap: 6px; margin-top: 8px; }
  .chat-input input { flex: 1; }

  /* rebind sąrašas */
  .rebind-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
  }
  .rebind-key {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
    padding: 3px 10px; font-family: monospace; font-size: 13px;
  }
  .rebind-row.listening .rebind-key { border-color: var(--accent); color: var(--accent-hi); }
  .guide-list { margin: 8px 0 8px 20px; font-size: 14px; }
  .guide-list li { margin-bottom: 6px; }
  .controls-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .controls-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
  .controls-table td:first-child { width: 45%; }
  .save-status {
    margin-top: 10px; padding: 12px; border: 1px dashed var(--border);
    border-radius: 8px; color: var(--text-dim); font-size: 13px;
  }

  /* modalai */
  .modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.7);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 20px;
  }
  .modal {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto;
    padding: 24px 26px; position: relative;
  }
  .modal h2 { margin-bottom: 12px; color: var(--accent-hi); }
  .modal p { margin-bottom: 10px; font-size: 14px; }
  .modal-close {
    position: absolute; top: 12px; right: 12px; background: none; border: none;
    color: var(--text-dim); font-size: 20px; cursor: pointer;
  }
  .modal-close:hover { color: var(--text); }
  .modal .btn-primary { margin-top: 12px; }

  /* onboarding stepper'is */
  .ob-step { display: none; }
  .ob-step.active { display: block; }
  .ob-step h3 { color: var(--accent-hi); margin-bottom: 8px; font-size: 15px; }
  .ob-step p { font-size: 14px; margin-bottom: 10px; }
  .ob-step kbd { font-size: 12px; }
  .ob-dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 10px; }
  .ob-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .2s; }
  .ob-dot.active { background: var(--accent); }
  .ob-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }

  /* footer */
  .site-footer {
    border-top: 1px solid var(--border); background: #0e0802;
    padding: 26px 20px; margin-top: 20px;
  }
  [data-theme="light"] .site-footer { background: #e4e7ee; }
  .footer-inner { max-width: 1300px; margin: 0 auto; }
  .footer-links { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0; }
  .footer-links a { color: var(--accent-2); text-decoration: none; font-size: 13.5px; }
  .footer-links a:hover { text-decoration: underline; }
  .footer-credits { color: var(--text-dim); font-size: 12.5px; }
  .footer-version { color: var(--border); font-size: 11.5px; font-family: monospace; }
  .footer-credits a { color: var(--accent-2); }

  /* lietimo valdikliai */
  .touch-layer { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
  .touch-layer > * { pointer-events: auto; }
  .touch-stick {
    position: absolute; left: 20px; bottom: 24px; width: 120px; height: 120px;
    border: 2px solid rgba(255,255,255,.25); border-radius: 50%;
    background: rgba(255,255,255,.05);
  }
  .touch-stick .nub {
    position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
    transform: translate(-50%,-50%); border-radius: 50%;
    background: rgba(255,140,0,.45); border: 2px solid rgba(255,180,80,.6);
  }
  .touch-btns { position: absolute; right: 18px; bottom: 20px; width: 170px; height: 140px; }
  .tbtn {
    position: absolute; width: 52px; height: 52px; border-radius: 50%;
    background: rgba(255,255,255,.10); border: 2px solid rgba(255,255,255,.3);
    color: #fff; font-size: 19px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    user-select: none; -webkit-user-select: none; touch-action: none;
  }
  .tbtn:active, .tbtn.pressed { background: rgba(255,140,0,.5); }
  .tbtn-x { right: 8px;   bottom: 44px; } /* ✕ */
  .tbtn-o { right: 64px;  bottom: 8px;  } /* ○ */
  .tbtn-s { right: 64px;  bottom: 80px; } /* □ */
  .tbtn-t { right: 120px; bottom: 44px; } /* △ */
  .tbtn-start { right: 0; bottom: 108px; width: 44px; height: 28px; border-radius: 14px; font-size: 10px; }
  .tbtn-sel   { right: 118px; bottom: 108px; width: 44px; height: 28px; border-radius: 14px; font-size: 10px; }

  /* skeleton loading */
  .skl-bar {
    height: 14px; border-radius: 6px;
    background: linear-gradient(90deg, var(--bg-raised) 25%, var(--border) 50%, var(--bg-raised) 75%);
    background-size: 200% 100%;
    animation: skl-shimmer 1.4s ease-in-out infinite;
  }
  @keyframes skl-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
  .skl td { padding: 8px 12px !important; }
  .skl .skl-bar.w-id { width: 24px; }
  .skl .skl-bar.w-name { width: 70%; }
  .skl .skl-bar.w-num { width: 40px; }
  .room-skl {
    border: 1px solid var(--border); border-radius: 8px; padding: 12px;
    margin-bottom: 8px; display: flex; gap: 12px; align-items: center;
  }
  .room-skl .skl-bar { flex: 1; }
  .rooms-empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }

  /* toast pranešimai */
  #toast-root {
    position: fixed; right: 16px; bottom: 16px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px; max-width: min(360px, 90vw);
  }
  .toast {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-left: 3px solid var(--accent-2); border-radius: 8px;
    padding: 10px 14px; font-size: 13.5px; color: var(--text);
    box-shadow: 0 6px 24px rgba(0,0,0,.4); cursor: pointer;
    animation: toast-in .25s ease-out;
  }
  .toast-success { border-left-color: #5fd35f; }
  .toast-error { border-left-color: var(--danger); }
  .toast.out { opacity: 0; transform: translateX(20px); transition: all .25s; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

  /* tekstiniai puslapiai (pages/) */
  .doc {
    max-width: 780px; margin: 0 auto; padding: 30px 20px 60px;
  }
  .doc h1 { font-size: 26px; color: var(--accent-hi); margin-bottom: 18px; }
  .doc h2 { font-size: 17px; color: var(--text); margin: 22px 0 8px; }
  .doc p, .doc li { color: var(--text-dim); font-size: 14.5px; margin-bottom: 8px; }
  .doc ul, .doc ol { margin: 8px 0 12px 22px; }
  .doc a { color: var(--accent-2); }
  .doc .doc-back {
    display: inline-block; margin-bottom: 20px; color: var(--accent-2);
    text-decoration: none; font-size: 14px;
  }
  .doc .doc-back:hover { text-decoration: underline; }
  .doc .doc-note {
    border-left: 3px solid var(--accent); padding: 8px 14px;
    background: rgba(255,140,0,.06); margin: 14px 0; font-size: 14px;
  }
  .doc input[type="text"], .doc input[type="email"], .doc textarea {
    width: 100%; margin-bottom: 10px;
    background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px;
    font-family: var(--font); font-size: 14px;
  }
  .doc textarea { min-height: 120px; resize: vertical; }

  /* responsive */
  @media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
    .panel { position: static; }
  }
  @media (max-width: 560px) {
    .game-title { font-size: 24px; }
    .header-inner { padding: 8px 12px; }
    .layout { padding: 14px 12px 30px; }
  }
  @media (orientation: portrait) and (max-width: 760px) {
    .game-toolbar { justify-content: center; }
    .game-hud { font-size: 11px; padding: 6px 8px; }
    .ad-slot { min-height: 60px; margin: 14px 0; }
    .panel { padding: 12px; }
    #toast-root { left: 12px; right: 12px; max-width: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .skl-bar { animation: none; background: var(--bg-raised); }
  }
}

/* ================= UTILITIES: vienos paskirties helper'iai ================= */
@layer utilities {
  .on  { color: #5fd35f; font-weight: 700; }
  .off { color: var(--text-dim); }
  .ok  { color: #5fd35f; font-weight: 700; }
  .bad { color: #e05f5f; font-weight: 700; }
  .dim { color: var(--text-dim); }
}
