/* Golix - arayuz stilleri */
:root {
  --bg: #101820;
  --bg2: #16212b;
  --panel: #1c2836;
  --panel2: #22303f;
  --line: #2e3f52;
  --text: #e6edf3;
  --dim: #8fa3b8;
  --red: #e56e56;
  --blue: #5689e5;
  --green: #6fbf73;
  --accent: #f0c95c;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1d2b38, var(--bg));
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }

.screen { display: none; height: 100%; }
.screen.active { display: block; }

/* ---------- ortak ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel.narrow {
  width: min(420px, 92vw);
  margin: 12vh auto 0;
  text-align: center;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { font-size: 15px; margin: 0; letter-spacing: .3px; }

.logo { font-size: 40px; margin: 0 0 4px; letter-spacing: -1px; font-weight: 800; }
.logo span { color: var(--accent); }
.logo.small { font-size: 20px; margin: 0; }
.sub { color: var(--dim); margin: 0 0 18px; }
.hint { color: var(--dim); font-size: 12px; margin: 10px 0 0; }

.field { display: block; text-align: left; margin: 0 0 12px; flex: 1; }
.field > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 9px 11px; background: #0f1720;
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.row { display: flex; gap: 10px; }
.avatar-field { flex: 0 0 78px; }
.avatar-field input { text-align: center; text-transform: uppercase; letter-spacing: 1px; }

.auth-panel { max-width: 440px; text-align: center; }
.auth-tabs { display: flex; gap: 6px; margin: 12px 0 16px; background: rgba(10, 16, 24, 0.6); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.btn-tab { flex: 1; padding: 7px 4px; border: none; background: transparent; color: var(--dim); border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.btn-tab.active { background: var(--accent); color: #101820; }

.team-selector-box {
  background: rgba(15, 23, 32, 0.75); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 14px; text-align: left;
}
.team-logo-preview {
  display: flex; align-items: center; justify-content: space-around; gap: 8px; margin-top: 10px;
  background: var(--panel); padding: 10px; border-radius: 8px; border: 1px solid var(--accent);
}
.logo-item { display: flex; align-items: center; gap: 8px; }
.logo-item img { width: 34px; height: 34px; object-fit: contain; }
.logo-item span { font-size: 13px; font-weight: 700; color: var(--text); }
.logo-divider { font-size: 14px; color: var(--accent); font-weight: bold; }

.auth-error { background: rgba(229, 110, 86, 0.15); border: 1px solid var(--red); color: #ff8a75; padding: 8px 12px; border-radius: 8px; font-size: 12px; margin-top: 10px; text-align: center; }

.avatar-presets { display: flex; align-items: center; justify-content: center; gap: 4px; margin: -4px 0 12px; font-size: 11px; color: var(--dim); }
.av-preset { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.av-preset:hover { background: var(--line); border-color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 9px 14px; border-radius: 8px; cursor: pointer;
  transition: filter .12s, transform .06s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .45; filter: none; transform: none; }
.btn.primary { background: linear-gradient(180deg, #2f7d4f, #24603d); border-color: #3a8f5c; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 11px; }
.btn.tiny.red { background: #7a3b30; border-color: #a4503f; }
.btn.tiny.blue { background: #2f4a80; border-color: #3f63a4; }
.hidden { display: none !important; }

/* ---------- lobi ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.conn { font-size: 12px; color: var(--dim); }
.conn.ok { color: var(--green); }
.conn.bad { color: var(--red); }

.lobby-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px;
  padding: 16px; height: calc(100% - 58px); align-items: start;
}
.room-list { max-height: calc(100vh - 190px); overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.room-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.room-row .rname { font-weight: 600; }
.room-row .meta { color: var(--dim); font-size: 12px; }
.room-row .grow { flex: 1; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: #2b3a4c; color: var(--dim); }
.badge.live { background: #43301d; color: var(--accent); }
.empty { color: var(--dim); text-align: center; padding: 24px; }

.lb-panel { grid-column: 1 / -1; }
.leaderboard { display: flex; flex-direction: column; gap: 3px; max-height: 240px; overflow: auto; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 6px; background: var(--panel2); font-size: 13px; }
.lb-row .rank { width: 22px; color: var(--dim); text-align: right; }
.lb-row .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .g { color: var(--accent); font-weight: 600; }
.lb-row .sub { color: var(--dim); font-size: 11px; }
.lb-row:nth-child(1) .rank { color: #f0c95c; }
.lb-row:nth-child(2) .rank { color: #cfd6dd; }
.lb-row:nth-child(3) .rank { color: #cf9b6a; }

/* ---------- oyun ---------- */
.game-wrap { display: grid; grid-template-columns: 1fr 270px; height: 100%; }
.stage { position: relative; overflow: hidden; background: #0b1219; display: flex; flex-direction: column; height: 100%; }
.canvas-wrap { flex: 1; position: relative; width: 100%; min-height: 0; background: #6a8552; overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; }

.overlay-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
  text-align: center; text-shadow: 0 3px 12px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .2s;
}
.overlay-msg.show { opacity: 1; }
.overlay-msg .big { font-size: 58px; font-weight: 900; letter-spacing: 2px; }
.overlay-msg .small { font-size: 18px; opacity: .9; }

.chat-area {
  position: relative;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: auto; flex: 0 0 auto;
}
.chat-log {
  display: flex; flex-direction: column; gap: 4px;
  height: 95px; max-height: 110px; overflow-y: auto;
  background: rgba(10, 16, 24, 0.75);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}
.chat-log div {
  font-size: 13px; text-shadow: none;
  max-width: 100%; padding: 1px 0; animation: fadein .15s;
  word-break: break-word;
}
.chat-log .cname { font-weight: 700; }
.chat-log .cname.red { color: #ff8a75; }
.chat-log .cname.blue { color: #8ab4ff; }
.chat-log .cname.spec { color: #dfe6ee; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
#chat-input {
  width: 100%; padding: 7px 12px; border-radius: 6px;
  background: rgba(16,24,32,0.95); border: 1px solid var(--line);
  color: #fff; font-size: 13px; outline: none; transition: border-color .15s;
  pointer-events: auto; opacity: 1;
}
#chat-input:focus { border-color: var(--accent); }

/* ---------- yan panel ---------- */
.side { background: var(--bg2); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.head-btns { display: flex; gap: 6px; flex: none; }
.teams { flex: 1; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 10px; }
.team-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); margin-bottom: 4px; }
.team.red .team-head { color: #ffb3a3; }
.team.blue .team-head { color: #a8c4ff; }
.team ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; min-height: 8px; }
.team li { display: flex; align-items: center; gap: 6px; background: var(--panel); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.team li .pn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team li .pg { color: var(--accent); font-size: 11px; }
.team li .pp { color: var(--dim); font-size: 11px; }
.team li.me { outline: 1px solid var(--accent); }
.team li .crown { font-size: 11px; }
.team li .kickbtn { cursor: pointer; color: var(--dim); background: none; border: 0; padding: 0 2px; }
.team li .kickbtn:hover { color: var(--red); }

.host-controls { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.host-controls .row { gap: 6px; }
.tiny-field { margin: 0; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); white-space: nowrap; cursor: pointer; }
.chk input { accent-color: var(--green); }
.bots-row { align-items: flex-end; }
.team li .robot { font-size: 11px; color: var(--dim); }
.tiny-field input, .tiny-field select { padding: 4px 6px; font-size: 12px; }
.side-foot { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; }

/* ---------- replay oynatici ---------- */
.replay-bar {
  position: absolute; left: 12px; right: 12px; bottom: 10px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(10,16,12,.78); border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(3px);
}
.replay-bar input[type=range] { flex: 1; accent-color: var(--accent); }
.rp-time { font-variant-numeric: tabular-nums; font-size: 12px; color: #dfe8df; }
.rp-speed { background: #0f1720; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.file-btn { display: inline-block; cursor: pointer; text-align: center; width: 100%; }
body.replay-mode .side { display: none; }
body.replay-mode .game-wrap { grid-template-columns: 1fr; }
body.replay-mode .chat-area { display: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%) translateY(-20px);
  background: #33222a; border: 1px solid #6b3b45; color: #ffd9d9;
  padding: 9px 16px; border-radius: 8px; opacity: 0; transition: all .2s; pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- emoji bar ---------- */
.emoji-bar {
  display: flex; gap: 6px; margin-bottom: 6px; pointer-events: auto; flex-wrap: wrap; align-items: center;
}
.btn-sticker {
  background: rgba(16,24,32,0.85); border: 1px solid var(--line);
  border-radius: 8px; padding: 2px 4px; cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-sticker img { width: 32px; height: 32px; object-fit: contain; display: block; }
.btn-sticker:hover { transform: scale(1.22); background: var(--panel2); border-color: var(--accent); }

.sticker-toggle {
  font-size: 11px; padding: 4px 10px; border-radius: 8px; background: rgba(16,24,32,0.9);
  color: var(--accent); border: 1px solid var(--accent); font-weight: 700; cursor: pointer;
}
.sticker-toggle:hover { background: var(--accent); color: #101820; }

.sticker-drawer {
  background: rgba(16,24,32,0.96); border: 1px solid var(--accent); border-radius: 12px;
  padding: 10px; margin-bottom: 8px; max-height: 180px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); backdrop-filter: blur(8px);
}
.sticker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px;
}
.btn-sticker-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center;
  gap: 4px; transition: transform .15s, background .15s, border-color .15s;
}
.btn-sticker-item img { width: 44px; height: 44px; object-fit: contain; }
.btn-sticker-item span { font-size: 10px; color: var(--text); font-weight: 600; text-align: center; line-height: 1.1; }
.btn-sticker-item:hover { transform: scale(1.1); background: var(--panel2); border-color: var(--accent); }

.btn-emoji {
  background: rgba(16,24,32,0.85); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font-size: 16px; cursor: pointer;
  transition: transform .1s, background .15s;
}
.btn-emoji:hover { transform: scale(1.2); background: var(--panel2); }
.btn-radio {
  background: rgba(16,24,32,0.85); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; font-size: 11px; cursor: pointer; color: var(--accent);
}
.btn-radio:hover { background: var(--panel2); }
#btn-ptt.active { background: var(--red) !important; color: #fff; border-color: #ff8a75; animation: pulse 1s infinite; }
.talking-badge { font-size: 10px; font-weight: 700; color: #4de896; background: rgba(77, 232, 150, 0.18); border: 1px solid #4de896; padding: 1px 5px; border-radius: 10px; animation: pulse 0.8s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.7; } 100% { opacity: 1; } }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: min(850px, 94vw); max-height: 90vh; overflow: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; }

/* Turnuva Braketi */
.tournament-bracket-view {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; background: rgba(10, 16, 24, 0.6);
  padding: 14px; border-radius: 12px; border: 1px solid var(--line);
}
.t-round h3 { font-size: 13px; text-transform: uppercase; color: var(--accent); margin: 0 0 8px 0; }
.t-match {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-size: 12px; font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.t-match.champion-match { border-color: #f0c95c; background: rgba(240, 201, 92, 0.12); }
.team-tag.red { color: #e56e56; }
.team-tag.blue { color: #5689e5; }

.editor-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.editor-canvas-wrap { background: #0b1219; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 10px; }
#editor-canvas { width: 100%; height: auto; display: block; border-radius: 4px; }
.editor-controls { display: flex; flex-direction: column; gap: 10px; }
.editor-controls label { font-size: 12px; }

/* ---------- mobil oyun kontrolleri ---------- */
.mobile-game-actions,
.mobile-controls,
.mobile-rotate-hint,
.mobile-scrim,
.mobile-side-close { display: none; }

@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; height: auto; overflow: auto; }
  #screen-game.active { overflow-y: auto; }
  .game-wrap { grid-template-columns: 1fr; grid-template-rows: minmax(560px, 100svh) auto; height: auto; min-height: 100%; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: none; overflow: visible; }
  .teams { flex: none; min-height: 96px; overflow: visible; }
  .stage { min-height: 560px; height: 100svh; }
  .canvas-wrap { min-height: 300px; }
  .editor-grid { grid-template-columns: 1fr; }
  /* Sohbet alani genis ekranda oldugu gibi 240px tutarsa sahayi ezer -
     mobilde daraltilip toplanabilir yapilir, saha (canvas-wrap: flex 1)
     kalan tum yuksekligi alir. */
  .chat-log { height: 46px; max-height: 46px; }
  .emoji-bar { gap: 4px; }
  .btn-sticker img { width: 24px; height: 24px; }
  .sticker-toggle { padding: 3px 7px; }
}

/* Telefon ve dokunmatik cihazlarda oyun, panel yerine tam ekran bir sahadir. */
@media (max-width: 900px), (pointer: coarse) {
  html, body {
    min-height: 100%;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
  }

  body { overflow: auto; }
  button, input, select { min-height: 42px; }
  input, select { font-size: 16px; }

  #screen-name.active,
  #screen-lobby.active {
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .panel.narrow {
    width: min(460px, calc(100vw - 24px));
    margin: max(18px, env(safe-area-inset-top)) auto 18px;
    padding: 16px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    background: rgba(16, 24, 32, .96);
    backdrop-filter: blur(8px);
  }
  .topbar .conn { order: 3; width: 100%; }
  .lobby-grid { padding: 10px; gap: 10px; }
  .panel { padding: 14px; }
  .row { flex-wrap: wrap; }
  .room-row { flex-wrap: wrap; }
  .room-row .grow { min-width: calc(100% - 64px); }

  #screen-game.active {
    position: fixed;
    inset: 0;
    z-index: 20;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background: #0b1219;
    overscroll-behavior: none;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  #screen-game.active .game-wrap {
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 0;
  }

  #screen-game.active .stage {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  #screen-game.active .canvas-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  #screen-game.active #canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    -ms-touch-action: none;
  }

  #screen-game.active .overlay-msg .big {
    max-width: 92vw;
    font-size: clamp(34px, 11vw, 54px);
    line-height: 1.02;
  }
  #screen-game.active .overlay-msg .small {
    max-width: 88vw;
    font-size: clamp(13px, 4vw, 18px);
    padding: 8px 12px;
  }

  #screen-game.active .chat-area {
    position: fixed;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 82;
    max-height: min(54dvh, 430px);
    padding: 10px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 14px;
    background: rgba(15, 23, 32, .96);
    box-shadow: 0 16px 44px rgba(0,0,0,.55);
    backdrop-filter: blur(10px);
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .2s ease, opacity .2s ease, visibility .2s;
  }
  body.mobile-chat-open #screen-game.active .chat-area {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  #screen-game.active .chat-log { height: 74px; max-height: 74px; }
  #screen-game.active #chat-input { min-height: 44px; font-size: 16px; }
  #screen-game.active .emoji-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  #screen-game.active .emoji-bar::-webkit-scrollbar { display: none; }
  #screen-game.active .btn-sticker { flex: 0 0 auto; min-width: 42px; min-height: 42px; }
  #screen-game.active .btn-sticker img { width: 30px; height: 30px; }
  #screen-game.active .sticker-toggle { flex: 0 0 auto; min-height: 42px; }
  #screen-game.active .sticker-drawer { max-height: min(35dvh, 260px); }

  #screen-game.active .side {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 92;
    width: min(350px, 88vw);
    max-height: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    border: 0;
    border-left: 1px solid var(--line);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: -18px 0 50px rgba(0,0,0,.52);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .2s ease, visibility .2s;
  }
  body.mobile-side-open #screen-game.active .side {
    transform: translateX(0);
    visibility: visible;
  }
  #screen-game.active .side-head {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-wrap: wrap;
    background: rgba(22,33,43,.97);
  }
  #screen-game.active .side-head > b { flex: 1; }
  #screen-game.active .mobile-side-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 9px;
    background: rgba(255,255,255,.07);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
  }
  #screen-game.active .side-head .head-btns {
    width: 100%;
    justify-content: flex-end;
  }
  #screen-game.active .teams { flex: none; min-height: 0; overflow: visible; }
  #screen-game.active .host-controls { flex: none; }
  #screen-game.active .side-foot { margin-top: auto; }
  #screen-game.active .head-btns { flex-wrap: wrap; justify-content: flex-end; }
  #screen-game.active .team-head .btn,
  #screen-game.active .head-btns .btn { min-height: 40px; }

  #screen-game.active .mobile-game-actions {
    position: absolute;
    z-index: 64;
    top: max(68px, calc(env(safe-area-inset-top) + 58px));
    right: max(8px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 7px;
    pointer-events: auto;
  }
  .mobile-action {
    min-width: 54px;
    min-height: 40px;
    padding: 7px 9px;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 11px;
    background: rgba(12,18,24,.74);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 5px 18px rgba(0,0,0,.28);
    backdrop-filter: blur(7px);
    touch-action: manipulation;
  }
  .mobile-action.icon { min-width: 42px; font-size: 20px; }
  .mobile-action.active { color: #101820; background: var(--accent); border-color: #ffe48d; }

  #screen-game.active .mobile-controls {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: block;
    pointer-events: none;
    transition: opacity .15s;
  }
  body.mobile-chat-open #screen-game.active .mobile-controls,
  body.mobile-side-open #screen-game.active .mobile-controls { opacity: .18; }

  .mobile-joystick {
    --stick-x: 0px;
    --stick-y: 0px;
    position: absolute;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: clamp(116px, 28vw, 148px);
    height: clamp(116px, 28vw, 148px);
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-joystick-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255,255,255,.38);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.10), rgba(8,15,20,.30));
    box-shadow: inset 0 0 24px rgba(255,255,255,.06), 0 8px 28px rgba(0,0,0,.26);
    backdrop-filter: blur(2px);
  }
  .mobile-joystick::before,
  .mobile-joystick::after {
    content: '';
    position: absolute;
    z-index: 1;
    background: rgba(255,255,255,.14);
    pointer-events: none;
  }
  .mobile-joystick::before { left: 50%; top: 15%; bottom: 15%; width: 1px; }
  .mobile-joystick::after { top: 50%; left: 15%; right: 15%; height: 1px; }
  .mobile-joystick-knob {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    width: 42%;
    height: 42%;
    border: 2px solid rgba(255,255,255,.62);
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(255,255,255,.34), rgba(255,255,255,.16));
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
    transition: transform .045s linear, background .1s;
    pointer-events: none;
  }
  .mobile-joystick.active .mobile-joystick-knob { background: rgba(240,201,92,.48); }
  .mobile-control-label {
    position: absolute;
    left: 50%;
    bottom: -18px;
    transform: translateX(-50%);
    color: rgba(255,255,255,.65);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1.1px;
    text-shadow: 0 1px 4px #000;
    pointer-events: none;
  }

  .mobile-kick {
    position: absolute;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    width: clamp(88px, 21vw, 108px);
    height: clamp(88px, 21vw, 108px);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 3px solid rgba(255,255,255,.62);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #f37d64, #a9342c 72%);
    color: #fff;
    box-shadow: 0 9px 28px rgba(0,0,0,.38), inset 0 2px 6px rgba(255,255,255,.28);
    font-size: 20px;
    font-weight: 950;
    letter-spacing: .5px;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .06s, filter .08s, box-shadow .08s;
  }
  .mobile-kick small { font-size: 7px; opacity: .72; letter-spacing: .8px; }
  .mobile-kick.active {
    transform: scale(.92);
    filter: brightness(1.25);
    box-shadow: 0 3px 12px rgba(0,0,0,.36), 0 0 22px rgba(255,110,86,.55);
  }

  #screen-game.active .mobile-scrim {
    position: fixed;
    inset: 0;
    z-index: 78;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(0,0,0,.48);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s, visibility .18s;
  }
  body.mobile-chat-open #screen-game.active .mobile-scrim,
  body.mobile-side-open #screen-game.active .mobile-scrim {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-rotate-hint { display: none; }
}

@media (max-width: 700px) and (orientation: portrait) {
  #screen-game.active .mobile-rotate-hint {
    position: absolute;
    z-index: 58;
    top: max(100px, calc(env(safe-area-inset-top) + 92px));
    left: 50%;
    display: block;
    max-width: 68vw;
    padding: 6px 10px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 20px;
    transform: translateX(-50%);
    background: rgba(12,18,24,.62);
    color: rgba(255,255,255,.78);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    animation: mobileHintFade 6s forwards;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .mobile-joystick {
    width: clamp(104px, 24vh, 126px);
    height: clamp(104px, 24vh, 126px);
    left: max(20px, calc(env(safe-area-inset-left) + 8px));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .mobile-kick {
    width: clamp(82px, 20vh, 100px);
    height: clamp(82px, 20vh, 100px);
    right: max(22px, calc(env(safe-area-inset-right) + 10px));
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  #screen-game.active .mobile-game-actions {
    top: max(62px, calc(env(safe-area-inset-top) + 54px));
  }
  .mobile-control-label {
    bottom: 7px;
    padding: 2px 5px;
    border-radius: 8px;
    background: rgba(10,16,20,.52);
    font-size: 7px;
  }
}

@keyframes mobileHintFade {
  0%, 72% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}
