/* ============================================================
   В ТЕМУ! — ui.css
   Shared components: pixel buttons, chips, status bar,
   toasts, modals, toggles. Sized with clamp() for mobile.
   ============================================================ */

/* ---- pixel bevel helper (khaki plastic card) ------------- */
.px-card {
  background: linear-gradient(#ddd0a2, var(--khaki) 55%, #c4b483);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.55),
    inset 3px 0 0 rgba(255,255,255,.28),
    inset 0 -4px 0 rgba(90,75,40,.5),
    0 4px 0 var(--ink);
}

/* ============================================================
   Menu buttons
   ============================================================ */

.mbtn {
  position: relative;
  display: flex; align-items: center; gap: clamp(12px, 3vw, 18px);
  width: 100%; height: clamp(52px, 11vw, 64px);
  padding: 0 clamp(16px, 4vw, 26px);
  font-family: var(--px-font); font-size: clamp(14px, 4.2vw, 20px); letter-spacing: 2px;
  color: var(--ink);
  background: linear-gradient(#ddd0a2, var(--khaki) 55%, #c4b483);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.55),
    inset 0 -4px 0 rgba(90,75,40,.5),
    0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform .09s ease, box-shadow .09s ease, background .12s;
}
.mbtn .mbtn-label { transform: translateY(1px); }
.mbtn .mbtn-ico { display: inline-flex; width: 28px; justify-content: center; }

@media (hover: hover) {
  .mbtn:hover {
    background: linear-gradient(#eee2b4, #e0d3a0 55%, #cfbf8d);
    transform: translateY(-2px);
    box-shadow:
      inset 0 3px 0 rgba(255,255,255,.6),
      inset 0 -4px 0 rgba(90,75,40,.5),
      0 7px 0 var(--ink),
      0 9px 18px rgba(0,0,0,.45);
  }
  .mbtn.primary:hover {
    background: linear-gradient(#daf4a4, #b3d56e 55%, #8cb14c);
    box-shadow:
      inset 0 3px 0 rgba(255,255,255,.55),
      inset 0 -4px 0 rgba(50,70,20,.55),
      0 7px 0 var(--ink),
      0 9px 20px rgba(120,180,60,.35);
  }
  .mbtn:hover::before { opacity: 1; transform: translateX(0); }
}
.mbtn.kb-focus {
  background: linear-gradient(#eee2b4, #e0d3a0 55%, #cfbf8d);
  transform: translateY(-2px);
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.6),
    inset 0 -4px 0 rgba(90,75,40,.5),
    0 7px 0 var(--ink),
    0 9px 18px rgba(0,0,0,.45);
}
.mbtn:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.4),
    inset 0 -2px 0 rgba(90,75,40,.5),
    0 2px 0 var(--ink);
}

.mbtn.primary {
  background: linear-gradient(#cbe98d, var(--green) 55%, #7da13e);
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.5),
    inset 0 -4px 0 rgba(50,70,20,.55),
    0 5px 0 var(--ink);
}

/* sliding cursor chevron that appears on hover */
.mbtn::before {
  content: ''; position: absolute; left: -34px; top: 50%;
  width: 14px; height: 14px; margin-top: -7px;
  background: var(--green-bright);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  opacity: 0; transform: translateX(-8px);
  transition: opacity .12s, transform .15s ease-out;
}
.mbtn.kb-focus::before { opacity: 1; transform: translateX(0); }

/* ============================================================
   Small control buttons (game screen)
   ============================================================ */

.cbtn {
  display: inline-flex; align-items: center; gap: clamp(6px, 1.6vw, 10px);
  height: clamp(42px, 9.6vw, 52px); padding: 0 clamp(10px, 2.6vw, 22px);
  font-family: var(--px-font); font-size: clamp(10px, 2.6vw, 14px); letter-spacing: 1px;
  color: var(--ink);
  background: linear-gradient(#ddd0a2, var(--khaki) 55%, #c4b483);
  border: 3px solid var(--ink); border-radius: 7px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), inset 0 -3px 0 rgba(90,75,40,.5), 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .1s, filter .1s;
}
@media (hover: hover) {
  .cbtn:hover { background: linear-gradient(#eee2b4, #e0d3a0 55%, #cfbf8d); transform: translateY(-1px);
    box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -3px 0 rgba(90,75,40,.5), 0 5px 0 var(--ink); }
  .cbtn.primary:hover { background: linear-gradient(#daf4a4, #b3d56e 55%, #8cb14c); }
}
.cbtn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 1px 0 var(--ink); }

.cbtn.primary { background: linear-gradient(#cbe98d, var(--green) 55%, #7da13e); }
.cbtn.primary:not(:disabled) { animation: submit-ready 1.4s ease-in-out infinite; }
@keyframes submit-ready {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.18) drop-shadow(0 0 10px rgba(160,220,90,.5)); }
}

.cbtn:disabled {
  background: linear-gradient(#5a5f4a, #4a4f3c);
  color: #8b8e77;
  cursor: not-allowed;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 4px 0 var(--ink);
  animation: none;
}

.icon-btn {
  width: clamp(44px, 10vw, 52px); height: clamp(44px, 10vw, 52px);
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(#ddd0a2, var(--khaki) 55%, #c4b483);
  border: 3px solid var(--ink); border-radius: 7px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
@media (hover: hover) {
  .icon-btn:hover { transform: translateY(-1px); box-shadow: inset 0 2px 0 rgba(255,255,255,.55), 0 5px 0 var(--ink); }
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ============================================================
   Chips (timer etc.)
   ============================================================ */

.chip {
  display: inline-flex; align-items: center; gap: clamp(6px, 1.6vw, 10px);
  height: clamp(38px, 8.6vw, 44px); padding: 0 clamp(10px, 2.4vw, 16px);
  flex: 0 0 auto;
  font-size: clamp(11px, 2.8vw, 15px); color: var(--green-text);
  background: var(--panel-2);
  border: 3px solid var(--ink); border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(170,200,110,.22), inset 0 2px 6px rgba(0,0,0,.5);
}

/* ============================================================
   Status bar (bottom of every view) — like the reference
   ============================================================ */

.status-bar {
  margin-top: auto;
  width: 100%; max-width: 900px; min-height: clamp(60px, 10vh, 84px);
  display: flex; align-items: stretch; justify-content: space-between; gap: 6px;
  padding: clamp(6px, 1.4vw, 10px) clamp(8px, 1.8vw, 14px);
  background: var(--panel);
  border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(170,200,110,.16), inset 0 3px 10px rgba(0,0,0,.55);
  font-size: clamp(9px, 2vw, 11px); color: var(--cream-dark);
}
.sb-cell { display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: 0 clamp(6px, 1.4vw, 12px); }
.sb-cell + .sb-cell { border-left: 2px dotted #3a4028; }
.sb-player { flex-direction: row; align-items: center; gap: clamp(8px, 1.8vw, 12px); }
.sb-player .sb-col { display: flex; flex-direction: column; gap: 7px; }
.sb-row { display: flex; align-items: center; gap: 8px; }
.sb-pips { display: inline-flex; gap: 3px; }
.sb-pips i { width: 9px; height: 9px; background: var(--red); box-shadow: inset -1px -2px 0 rgba(0,0,0,.35); }
.sb-pips i.dim { background: #3a4028; box-shadow: none; }
.sb-level { align-items: center; text-align: center; flex: 0 0 auto; }
.sb-level .sb-num { font-size: clamp(16px, 3.6vw, 22px); color: var(--green); text-shadow: 0 0 12px rgba(157,193,87,.55); }
.sb-level .sb-cap { color: var(--dim); }
.sb-sys { margin-left: auto; flex-direction: row; align-items: center; gap: 14px; }
.sb-sys .sb-col { display: flex; flex-direction: column; gap: 5px; color: var(--dim); }
.sb-sys .sb-col b { color: var(--cream-dark); font-weight: 400; }

@media (max-width: 760px) { .sb-sys { display: none; } .sb-level { margin-left: auto; } }
@media (max-width: 470px) { .sb-level { display: none; } .sb-pips { display: none; } }

/* ============================================================
   Toasts
   ============================================================ */

#toast-root {
  /* z 39: achievement toasts must ride above the modal veil (38) */
  position: absolute; top: clamp(90px, 16vh, 130px); left: 0; right: 0; z-index: 39;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: clamp(10px, 2.4vw, 14px) clamp(16px, 4vw, 24px);
  font-size: clamp(11px, 2.8vw, 14px); letter-spacing: 1px; color: var(--ink);
  background: linear-gradient(#eee2b4, var(--khaki));
  border: 3px solid var(--ink); border-radius: 7px;
  box-shadow: 0 4px 0 var(--ink), 0 10px 24px rgba(0,0,0,.5);
  animation: toast-in .18s ease-out both;
}
.toast.err  { background: linear-gradient(#e88a70, var(--red)); color: #fff3ea; }
.toast.good { background: linear-gradient(#cbe98d, var(--green)); }
.toast.out  { animation: toast-out .2s ease-in both; }
@keyframes toast-in  { from { transform: translateY(-16px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-10px) scale(.92); opacity: 0; } }

/* ============================================================
   Modals
   ============================================================ */

#modal-root { position: absolute; inset: 0; z-index: 38; pointer-events: none; }
.modal-veil {
  position: absolute; inset: 0;
  background: rgba(5, 8, 4, .72);
  pointer-events: auto;
  animation: veil-in .2s ease both;
}
@keyframes veil-in { from { opacity: 0; } }
.modal-veil.out { animation: veil-out .18s ease both; }
@keyframes veil-out { to { opacity: 0; } }

.modal {
  position: absolute; left: 50%; top: 50%;
  min-width: min(430px, 94vw); max-width: min(640px, 94vw);
  transform: translate(-50%, -50%);
  background: var(--panel-2);
  border: 3px solid var(--ink); border-radius: 10px;
  box-shadow:
    inset 0 0 0 2px rgba(170,200,110,.25),
    inset 0 4px 14px rgba(0,0,0,.5),
    0 16px 40px rgba(0,0,0,.6);
  padding: clamp(18px, 4.6vw, 26px) clamp(16px, 4.6vw, 30px);
  pointer-events: auto;
  animation: modal-in .22s cubic-bezier(.34,1.56,.64,1) both;
}
.modal.out { animation: modal-out .16s ease-in both; }
@keyframes modal-in  { from { transform: translate(-50%,-50%) scale(.7); opacity: 0; } }
@keyframes modal-out { to   { transform: translate(-50%,-46%) scale(.85); opacity: 0; } }

/* corner brackets like the reference frame kit */
.modal::before, .modal::after,
.modal .corner-b::before, .modal .corner-b::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  border: 3px solid var(--khaki);
}
.modal::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.modal::after  { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.modal .corner-b::before { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.modal .corner-b::after  { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

.modal-title {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: clamp(14px, 3.8vw, 19px); letter-spacing: 2px; color: var(--cream);
  text-align: center; margin-bottom: 6px;
  text-shadow: 3px 3px 0 rgba(0,0,0,.6);
}
.modal-sub { text-align: center; font-size: clamp(9px, 2.4vw, 11px); color: var(--green-text); margin-bottom: 18px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.modal-btns { display: flex; gap: clamp(8px, 2.4vw, 14px); justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.modal .dotted-rule {
  width: 100%; height: 3px; margin: 4px 0 12px;
  background: repeating-linear-gradient(90deg, #46502e 0 6px, transparent 6px 12px);
}

/* settings rows */
.set-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 12px 14px;
  background: var(--panel);
  border: 2px solid var(--ink); border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(170,200,110,.14);
  font-size: clamp(11px, 2.8vw, 13px); color: var(--cream-dark);
}
.set-row .set-label { display: flex; align-items: center; gap: 12px; }

/* pixel toggle */
.ptoggle {
  position: relative; width: 74px; height: 32px; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 16px;
  background: linear-gradient(#8a4437, #6e352b);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.5);
  transition: background .15s;
  flex: 0 0 auto;
}
.ptoggle .knob {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdf6dd, var(--cream) 60%, #b9aa7d);
  box-shadow: 0 2px 3px rgba(0,0,0,.45);
  transition: left .16s cubic-bezier(.34,1.4,.64,1);
}
.ptoggle.on { background: linear-gradient(#7fa348, #5d7a34); }
.ptoggle.on .knob { left: 44px; }
.ptoggle .t-cap { position: absolute; top: 50%; transform: translateY(-50%); font-size: 8px; color: rgba(255,255,255,.8); }
.ptoggle .t-on  { left: 9px;  display: none; }
.ptoggle .t-off { right: 6px; }
.ptoggle.on .t-on { display: block; }
.ptoggle.on .t-off { display: none; }

/* dotted decorative rules with chevrons (used in headers) */
.tagline-row { display: flex; align-items: center; gap: 18px; }
.chev { width: 58px; height: 12px; }
