﻿/* ================= Панель обучающей сцены ================= */
#tutPanel {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(560px, 94%); z-index: 14;
  background: rgba(14, 16, 26, .93); border: 1px solid rgba(255,255,255,.12);
  border-left: 4px solid var(--accent); border-radius: 12px;
  padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
#tutPanel .tp-head { display: flex; align-items: center; gap: 10px; }
#tutPanel .tp-step { font-family: var(--font-display); font-size: 12px; letter-spacing: 2px; color: var(--accent-2); text-transform: uppercase; }
#tutPanel .tp-dots { display: flex; gap: 4px; margin-left: auto; }
#tutPanel .tp-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); }
#tutPanel .tp-dots i.done { background: #2ecc71; }
#tutPanel .tp-dots i.cur { background: var(--accent); }
#tutPanel .tp-title { font-family: var(--font-display); font-size: 20px; letter-spacing: .5px; margin: 4px 0 2px; }
#tutPanel .tp-text { font-size: 13.5px; line-height: 1.45; color: #d5d8e0; }
#tutPanel .tp-text kbd {
  display: inline-block; padding: 0 6px; border-radius: 4px; font-family: inherit; font-size: 12px; font-weight: 700;
  background: #f3ead8; color: #2b2620; box-shadow: 0 2px 0 #b9ad96;
}
#tutPanel .tp-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
#tutPanel .tp-actions button { padding: 7px 14px; font-size: 14px; }
#tutPanel.done { border-left-color: #2ecc71; }
#tutPanel .tp-x { display: none; }
/* ПК: панель стоит в правой колонке над событиями */
#rightbar #tutPanel { position: static; transform: none; width: auto; flex-shrink: 0; padding: 12px 14px; }
#rightbar #tutPanel .tp-actions { justify-content: stretch; }
#rightbar #tutPanel .tp-actions button { flex: 1; }

/* ================= Сенсорное управление ================= */
/* Раскладка: [джойстик | поле | кнопки]. Поле не перекрывается ничем. */
#touchLeft, #touchRight { display: none; }
body.touch {
  --colL: calc(clamp(132px, 19vw, 210px) + env(safe-area-inset-left));
  --colR: calc(clamp(178px, 22vw, 230px) + env(safe-area-inset-right));
}
body.touch #app {
  padding: 0 var(--colR) 0 var(--colL); gap: 0;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
body.touch #gameWrap { border-radius: 10px; }
body.touch #gameWrap.cam { overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,.5); background: #2c2c3e; }
body.touch #gameWrap.cam #cv { border-radius: 0; box-shadow: none; transform-origin: 0 0; }

/* --- левая колонка: джойстик --- */
body.touch #touchLeft {
  display: block; position: fixed; left: 0; top: 0; bottom: 0; width: var(--colL); z-index: 20;
  background: linear-gradient(90deg, rgba(255,255,255,.025), transparent);
}
#joyZone { position: absolute; inset: 0; touch-action: none; }
#joyBase {
  position: absolute; left: calc(50% + env(safe-area-inset-left) / 2); top: calc(100% - 96px);
  width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.05), rgba(255,255,255,.12));
  border: 2px solid rgba(255,255,255,.2);
  opacity: .5; transition: opacity .15s;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#joyBase.on { opacity: 1; }
#joyKnob {
  width: 50px; height: 50px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffbe73, var(--accent));
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  will-change: transform;
}
.joy-hint {
  position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); padding-left: env(safe-area-inset-left);
  text-align: center; font-size: 10.5px; color: rgba(255,255,255,.4); pointer-events: none;
}

/* --- правая колонка: чат/эмодзи/звук сверху, бомба и перекат снизу --- */
body.touch #touchRight {
  display: flex; flex-direction: column; justify-content: space-between;
  position: fixed; right: 0; top: 0; bottom: 0; width: var(--colR); z-index: 20;
  padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) 8px;
  background: linear-gradient(270deg, rgba(255,255,255,.025), transparent);
  pointer-events: none;
}
.tr-top { display: flex; gap: 6px; justify-content: flex-end; }
.tr-actions { position: relative; height: 172px; }
.tbtn {
  pointer-events: auto; touch-action: none;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.22);
  background: rgba(20, 24, 36, .8); color: #fff; padding: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.45);
  transition: transform .06s, background .1s, opacity .2s;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tbtn.down { transform: scale(.9); }
.tbtn.small { width: 40px; height: 40px; font-size: 18px; }
.tbtn.small.off { opacity: .45; }
/* одинаковые большие кнопки: перекат выше-левее бомбы — под дугу большого пальца */
.tbtn.act { position: absolute; width: 76px; height: 76px; font-size: 34px; }
.act-bomb { right: 6px; bottom: 6px; --c: #ff9a2e; border-color: rgba(255,154,46,.55); }
.act-dash { right: 88px; bottom: 82px; --c: #5ee0ff; border-color: rgba(94,224,255,.5); }
.act-dash.hyper { --c: #ffa53b; border-color: rgba(255,165,59,.6); }
.tbtn.act.down { background: rgba(232,135,30,.85); }
.tbtn.act .ico { line-height: 1; transition: opacity .15s, filter .15s; }
/* кольцо прогресса: у бомбы — сколько бомб в запасе, у переката — перезарядка */
.tbtn.act .ring {
  position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--c) calc(var(--p, 100) * 1%), rgba(255,255,255,.1) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
.act-bomb .cnt {
  position: absolute; right: -4px; top: -4px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 13px; background: #ff9a2e; color: #1a1206; border: 2px solid #12141c;
  font-size: 14px; font-weight: 800; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
.act-bomb.empty .ico { opacity: .35; filter: grayscale(1); }
.act-bomb.empty .cnt { background: #5a5f70; color: #fff; }
.act-dash .cd {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 24px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.8); pointer-events: none;
}
.act-dash.hyper:not(.cooling) .cd { font-size: 13px; align-items: flex-end; padding-bottom: 6px; color: #ffcf8a; }
.act-dash.cooling .ico { opacity: .3; filter: grayscale(1); }
#touchRight.idle .tr-actions { opacity: .3; }

/* --- HUD на телефоне: в левой колонке над джойстиком --- */
body.touch #sidebar {
  position: fixed; top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left));
  width: calc(var(--colL) - 12px - env(safe-area-inset-left)); height: auto !important; z-index: 25; pointer-events: none;
}
body.touch #playerCards { flex-direction: row; flex-wrap: wrap; gap: 4px; overflow: visible; }
body.touch .pcard {
  grid-template-columns: 26px; grid-template-rows: 26px; padding: 2px; gap: 0;
  border-left-width: 1px; border-radius: 50%; background: rgba(14,16,26,.75);
}
body.touch .pcard .ava { width: 26px; height: 26px; grid-row: 1; border-width: 1px; }
body.touch .pcard .ava canvas { width: 22px; height: 22px; }
body.touch .pcard .ava .rank { display: none; }
body.touch .pcard .ava .skull { font-size: 13px; }
body.touch .pcard .pname, body.touch .pcard .stats, body.touch .pcard .fx, body.touch .pcard .status-dead { display: none; }
body.touch .pcard.me .status-dead { display: block; grid-column: 2; }
/* своя карточка — во всю ширину колонки, со статами и эффектами */
body.touch .pcard.me {
  width: 100%; grid-template-columns: 30px 1fr; grid-template-rows: 16px auto; gap: 1px 7px;
  border-radius: 10px; padding: 4px 6px; align-items: center;
}
body.touch .pcard.me .ava { width: 30px; height: 30px; grid-row: 1 / 3; }
body.touch .pcard.me .ava canvas { width: 26px; height: 26px; }
body.touch .pcard.me .stats { display: flex; gap: 6px; font-size: 12px; line-height: 16px; }
body.touch .pcard.me .stats .dash { display: none; }
body.touch .pcard.me .fx { display: flex; grid-column: 2; height: 18px; }
body.touch .sidebar-foot { display: none; }

/* --- чат: лента в правой колонке, поле ввода — сверху по центру --- */
body.touch #rightbar {
  position: fixed; top: calc(56px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right));
  width: calc(var(--colR) - 12px - env(safe-area-inset-right)); height: auto !important;
  max-height: calc(100dvh - 56px - 196px); overflow: hidden; z-index: 25; pointer-events: none;
}
body.touch #rightbar .rb-title, body.touch #feed { display: none; }
body.touch #rightbar #tutPanel { display: none; }
body.touch #chatLog { max-height: none; }
body.touch #chatLog .msg { font-size: 11px; padding: 3px 7px; background: rgba(0,0,0,.55); }
body.touch #chatBox.open #chatInput {
  position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(440px, 58vw); z-index: 60; pointer-events: auto;
  font-size: 16px; /* 16px — чтобы iOS не увеличивал страницу при вводе */
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}

/* колесо эмодзи — компактнее */
body.touch #emoteWheel { transform: translate(-50%, -50%) scale(.7); }
body.touch #emoteWheel.show { transform: translate(-50%, -50%) scale(.8); }
body.touch #overlay .rank-row { min-width: 0; width: min(360px, 90%); }
body.touch #overlay .title { font-size: 24px; }

/* панель обучения: компактная полоска у верхнего края поля */
body.touch #tutPanel {
  bottom: auto; top: 4px; width: min(430px, 92%); padding: 5px 10px;
  background: rgba(14, 16, 26, .8); pointer-events: auto;
}
body.touch #tutPanel.at-bottom { top: auto; bottom: 4px; }
/* на телефоне места над полем нет: тикер — тонкой полосой поверх верхнего края арены */
body.touch #fieldCol { gap: 0; }
body.touch #notices { position: absolute; left: 6px; right: 6px; top: 4px; height: 38px; }
body.touch #fieldCol:has(#tutPanel:not(.hidden):not(.at-bottom)) #notices { top: 92px; }
body.touch .tk { padding-left: 50px; }
body.touch .tk-art { width: 38px; height: 38px; left: 6px; bottom: 2px; }
body.touch .tk-t { font-size: 15px; }
body.touch .tk-d { font-size: 12px; }
body.touch .cb-art { width: 34px; height: 34px; }
body.touch .cb b { font-size: 14px; }
body.touch .cb-n { font-size: 30px; }
body.touch #tutPanel .tp-step { font-size: 10px; letter-spacing: 1px; }
body.touch #tutPanel .tp-dots i { width: 6px; height: 6px; }
body.touch #tutPanel .tp-title { display: none; }
body.touch #tutPanel .tp-text { font-size: 12px; line-height: 1.35; }
body.touch #tutPanel:not(.done) .tp-actions { display: none; }
body.touch #tutPanel .tp-actions button { padding: 5px 10px; font-size: 12.5px; }
body.touch #tutPanel .tp-x {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  background: rgba(255,255,255,.1); border: none; color: #fff; font-size: 12px;
}
body.touch .notice { padding: 5px 10px 5px 8px; }
body.touch .notice .ni svg { width: 18px; height: 18px; }
body.touch .notice .nt { font-size: 13px; }
body.touch .notice .nd { font-size: 11px; }

/* низкий экран: кнопки чуть меньше */
@media (max-height: 360px) {
  body.touch { --colR: calc(160px + env(safe-area-inset-right)); }
  .tbtn.act { width: 66px; height: 66px; font-size: 30px; }
  .act-dash { right: 78px; bottom: 72px; }
  .tr-actions { height: 150px; }
  .tbtn.small { width: 36px; height: 36px; font-size: 16px; }
}
