/* Somente janelas: a arena, o HUD, o mapa e as cartas da partida mantêm seu visual. */
#modal,
#pause {
  --cream: #f3f0df;
  --lime: #d6f266;
  --muted: #a3ad99;
  --line: #ffffff20;
  --orange: #ff824c;
  color: var(--cream);
  background: #0c100bd1;
  backdrop-filter: blur(8px);
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow: hidden;
}

#modal .modal-box {
  display: flex;
  flex-direction: column;
  flex-shrink: 1;
  gap: 18px;
  position: relative;
  width: min(94vw, 560px);
  min-height: 0;
  max-height: 100%;
  padding: 26px;
  text-align: left;
  background: #222a22;
  border: 1px solid #596649;
  border-radius: 8px;
  box-shadow: 0 24px 100px #0008;
}

#modal .modal-box.wide {
  width: min(100%, 920px);
}

.modal-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 48px;
  color: var(--muted);
  font: 8px monospace;
  letter-spacing: 1.5px;
}

.modal-masthead i {
  color: var(--lime);
  margin: 0 8px;
  font-style: normal;
}

.modal-masthead>span:last-child {
  color: var(--orange);
}

#modal #modal-title {
  flex: none;
  margin: 0;
  justify-content: flex-start;
  padding-right: 30px;
  min-width: 0;
  font-size: 28px;
  font-weight: 850;
  letter-spacing: -1px;
  line-height: 1.15;
  color: var(--cream);
}

#modal-title>span {
  min-width: 0;
}

#modal #modal-title small {
  color: var(--muted);
  font: 10px monospace;
  margin-left: 12px;
  letter-spacing: 0;
  white-space: nowrap;
}

#modal #modal-title .nav {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #5b684e;
  border-radius: 4px;
  color: var(--lime);
  background: #2e3829;
  font-size: 10px;
}

#modal #modal-title .nav:hover {
  background: #3e4c30;
}

#modal #modal-body,
#modal #modal-body.log {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 8px;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: #6e8057 transparent;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 450;
  color: #d6dccd;
}

#modal-body> :first-child {
  margin-top: 0;
}

#modal-body> :last-child {
  margin-bottom: 0;
}

#modal .btn,
#pause .btn {
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid #5d6a4f;
  border-radius: 4px;
  background: #303a2b;
  color: var(--cream);
  box-shadow: none;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-shadow: none;
}

#modal .btn:hover,
#pause .btn:hover {
  border-color: var(--lime);
  background: #3b4930;
}

#modal .btn:active,
#pause .btn:active {
  border-width: 1px;
  transform: translateY(1px);
}

#modal .btn.primary,
#pause .btn.primary {
  border-color: var(--lime);
  background: var(--lime);
  color: #20291a;
  font-weight: 850;
}

#modal .btn.primary:hover,
#pause .btn.primary:hover {
  background: #e7ff93;
}

#modal button:focus-visible,
#modal input:focus-visible,
#pause button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

#modal #modal-x {
  position: absolute;
  top: 17px;
  right: 18px;
  min-height: 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: #c7cfbc;
  background: transparent;
  border: 1px solid #5a664c;
}

.modal-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.modal-footer>small {
  color: #8b9880;
  font-size: 7px;
  letter-spacing: 1.3px;
}

.modal-footer kbd:not(.pad-on) {
  margin-left: 10px;
  padding: 2px 4px;
  background: #ffffff0d;
  border: 1px solid #ffffff20;
  border-radius: 2px;
  color: #a4b196;
  font: 8px monospace;
}

#modal .hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

#modal .modal-lead {
  color: #b4bfaa;
  font-size: 12px;
  margin: 0 0 18px;
}

/* Configurações com controles maiores e contraste claro. */
#modal #modal-body>label {
  display: block;
  position: relative;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 13px 12px 13px 43px;
  border: 1px solid #48543d;
  border-radius: 5px;
  background: #293226;
  font-size: 12px;
  cursor: pointer;
}

#modal-body input {
  accent-color: var(--lime);
}

#modal-body input[type=checkbox] {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  width: 17px;
  height: 17px;
  cursor: pointer;
}

#modal #modal-body>label:has(input[type=range]) {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px 16px;
  color: var(--lime);
  font-weight: 700;
}

#modal-body input[type=range] {
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

#modal #modal-body>label.settings-name {
  display: grid;
  gap: 7px;
  padding: 12px 16px;
  cursor: text;
  color: var(--lime);
  font-weight: 700;
}

.settings-name input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #657452;
  border-radius: 4px;
  background: #182017;
  color: var(--cream);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.settings-name small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 450;
}

/* Perfil, classificação e novidades. */
.profile-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #58684a;
  background: #34412b;
  border-radius: 5px;
  padding: 16px;
  margin-bottom: 14px;
}

.profile-banner>.ui-icon {
  width: 36px;
  height: 36px;
  color: var(--lime);
  padding: 7px;
  background: #d6f2660a;
}

.profile-banner>div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.profile-banner small {
  font-size: 7px;
  letter-spacing: 1.2px;
  color: #a6b596;
}

.profile-banner b {
  font-size: 22px;
  color: var(--cream);
  overflow-wrap: anywhere;
}

.profile-banner>span {
  margin-left: auto;
  font: 10px monospace;
  color: var(--lime);
  white-space: nowrap;
}

#modal table.stats {
  font-size: 12px;
}

#modal table.stats td {
  padding: 10px 2px;
  border-color: #ffffff12;
  color: #bac4ae;
}

#modal table.stats td:last-child {
  color: var(--cream);
  font-weight: 750;
}

#modal table.stats tr:nth-child(even) {
  background: #ffffff02;
}

/* Abas e lista da Classificação (Global e Aparelho) */
.ranking-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ranking-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 12px;
  background: #283324;
  border: 1px solid #4c5b3e;
  border-radius: 4px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s ease;
}

.ranking-tabs button:hover {
  border-color: var(--lime);
  color: var(--cream);
  background: #32402d;
}

.ranking-tabs button.active {
  background: var(--lime);
  color: #1f271a;
  border-color: var(--lime);
  font-weight: 850;
  box-shadow: 0 2px 8px #d6f26620;
}

/* Abas e modo juntos preservam espaço para os resultados em telas baixas. */
#modal .ranking-view { width: min(94vw, 720px); }
.ranking-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.ranking-controls .ranking-tabs { flex: 1; margin: 0; padding: 0; border: 0; gap: 6px; }
.ranking-controls .ranking-mode-bar { margin: 0; }
#modal .ranking-tabs .btn.active { background: var(--lime); border-color: var(--lime); color: #1f271a; }
#modal .ranking-view .ranking-filter-bar { flex-wrap: wrap; }
#modal .ranking-view select { min-height: 30px; }

.ranking-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.ranking-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ranking-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ranking-filter-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.rank-char-select {
  background: #283324;
  border: 1px solid #4c5b3e;
  border-radius: 4px;
  color: var(--cream);
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  max-width: 200px;
  text-overflow: ellipsis;
}

.rank-char-select:hover,
.rank-char-select:focus {
  border-color: var(--lime);
}

.ranking-pos-badge {
  font: 700 9px monospace;
  color: var(--lime);
  background: #d6f26615;
  border: 1px solid #d6f26630;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.btn-refresh {
  background: transparent;
  border: 1px solid #5d6a4f;
  border-radius: 4px;
  color: var(--lime);
  cursor: pointer;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.btn-refresh:hover {
  background: #3b4930;
  border-color: var(--lime);
}

#modal ol.rank {
  display: flex;
  flex-direction: column;
  gap: 7px;
  list-style: none;
  padding: 0;
  margin: 0;
}

#modal ol.rank li {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #46543a;
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 12px;
  background: #283223;
  transition: background .12s ease;
}

#modal ol.rank li.me {
  background: #2e3e25;
  border-color: #8fa85b;
  box-shadow: inset 3px 0 0 var(--lime);
}

#modal ol.rank li:hover {
  background: #303d2a;
}

.ranking-pos {
  flex: none;
  width: 26px;
  font-weight: 850;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.ranking-pos.top-1 {
  font-size: 18px;
  line-height: 1;
}

.ranking-pos.top-2 {
  font-size: 17px;
  line-height: 1;
}

.ranking-pos.top-3 {
  font-size: 16px;
  line-height: 1;
}

.ranking-user {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ranking-user-line {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.ranking-user-line>b {
  font-size: 13px;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me-tag {
  flex: none;
  display: inline-block;
  background: var(--lime);
  color: #1f271a;
  font: 800 8px monospace;
  letter-spacing: .5px;
  padding: 1px 5px;
  border-radius: 3px;
}

.presence-tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  font: 700 8px monospace;
  letter-spacing: .3px;
  border: 1px solid #ffffff1a;
  background: #ffffff08;
  color: var(--muted);
  white-space: nowrap;
}

.presence-tag b {
  font: inherit !important;
  color: inherit !important;
}

.presence-tag i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6c7863;
  display: inline-block;
  flex: none;
}

.presence-tag.online {
  color: #8ef59a;
  background: #2ecc711c;
  border-color: #2ecc7155;
}

.presence-tag.online i {
  background: #2ecc71;
  box-shadow: 0 0 6px #2ecc71;
}

.presence-tag.playing {
  color: #ffd27d;
  background: #ff824c22;
  border-color: #ff824c66;
}

.presence-tag.playing i {
  background: #ff9f43;
  box-shadow: 0 0 6px #ff9f43;
}

.ranking-char {
  color: var(--muted);
  font-size: 10px;
}

.ranking-score {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.ranking-score b {
  color: var(--lime) !important;
  font-size: 13px !important;
  font-weight: 800;
  white-space: nowrap;
}

.ranking-score small {
  color: var(--muted);
  font-size: 10px;
}

.ranking-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 10px;
  color: var(--muted);
  font-size: 12px;
}

.ranking-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #ffffff20;
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: rank-spin .8s linear infinite;
}

@keyframes rank-spin {
  to {
    transform: rotate(360deg);
  }
}

.ranking-offline {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 14px;
  background: #2e2624;
  border: 1px dashed #7a5042;
  border-radius: 6px;
  color: #ffccbc;
}

.ranking-offline p {
  margin: 0 0 10px;
  font-size: 12px;
}

.ranking-offline .hint {
  color: #d7ccc8;
  margin-top: 8px;
  font-size: 11px;
}

.empty-ranking {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 25px 12px;
  border: 1px dashed #5d6b4e;
  border-radius: 5px;
}

.empty-ranking>.ui-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  color: var(--lime);
}

.empty-ranking b {
  color: var(--cream);
  font-size: 18px;
  letter-spacing: -.5px;
}

.empty-ranking p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

/* Badge de novo recorde e sincronização com ranking na tela de resultado */
.record-badge {
  display: inline-block;
  padding: 5px 14px;
  margin: 0 auto 10px;
  background: linear-gradient(135deg, #ffd23f, #ff824c);
  color: #1a1500;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: .8px;
  border-radius: 16px;
  box-shadow: 0 0 16px rgba(255, 210, 63, .45);
  animation: pulse-record 1.2s infinite alternate ease-in-out;
}

@keyframes pulse-record {
  from {
    transform: scale(0.97);
    filter: drop-shadow(0 0 4px #ffd23f);
  }

  to {
    transform: scale(1.03);
    filter: drop-shadow(0 0 12px #ff824c);
  }
}

.res-global-sync {
  margin-top: 6px;
  font-size: 11px;
}

.sync-success {
  color: #98ee99;
  font-weight: 600;
}

#modal .rel {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

#modal .rel:first-child {
  padding-top: 0;
}

#modal .rel:last-child {
  border: 0;
}

#modal .rel h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 9px;
  color: var(--lime);
  font: 700 16px monospace;
}

#modal .rel h3 small {
  color: #9eac91;
  font: 10px monospace;
}

#modal .rel ul {
  font-size: 12px;
  line-height: 1.65;
  color: #c5cebb;
  padding-left: 18px;
}

#modal .rel li+li {
  margin-top: 6px;
}

#modal .rel li::marker {
  color: var(--orange);
}

/* Ficha do personagem: painéis e barras na mesma linguagem do arsenal. */
#modal .cdgrid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
}

#modal .cd {
  padding: 14px;
  border: 1px solid #47543c;
  border-radius: 5px;
  background: #293225;
  gap: 12px;
  margin-bottom: 12px;
}

#modal .cdgrid>.cd {
  margin-bottom: 0;
}

#modal .cd h4 {
  color: var(--lime);
  font-size: 10px;
  letter-spacing: 1px;
  margin: 15px 0 7px;
}

#modal .cd h4:first-child {
  margin-top: 0;
}

#modal .cd h4.pro {
  color: #d6f266;
}

#modal .cd h4.con {
  color: var(--orange);
}

#modal .cd p,
#modal .cd ul {
  color: #c2cdb6;
  font-size: 12px;
  line-height: 1.55;
}

#modal .cd ul {
  padding-left: 16px;
}

#modal .cd li+li {
  margin-top: 5px;
}

#modal #cd-img {
  gap: 10px;
}

#modal #cd-img canvas {
  width: 76px;
  height: 91px;
  filter: drop-shadow(3px 6px 5px #0005);
}

#modal #cd-img .btn {
  min-height: 30px;
  font-size: 9px;
  padding: 6px;
  white-space: nowrap;
}

#modal .stat {
  grid-template-columns: 64px minmax(20px, 1fr) 35px;
  gap: 7px;
  font-size: 10px;
  margin: 7px 0;
  color: #b7c5a9;
}

#modal .stat b {
  color: var(--cream);
  font-size: 10px;
}

#modal .sbar {
  height: 4px;
  background: #ffffff12;
  border-radius: 2px;
}

#modal .sbar i {
  background: var(--lime);
  border-radius: 2px;
}

#modal #cd-pick {
  width: 100%;
  min-height: 40px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 4px;
  box-shadow: none;
  background: var(--lime);
  border-color: var(--lime);
  color: #20291a;
  font-size: 12px;
}

#modal #cd-pick.on {
  color: var(--lime);
  background: #35432b;
  border-color: #73855b;
  cursor: default;
}

/* Coleção de habilidades: a janela muda; o botão e as cartas na arena não. */
#modal .sk-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #61744d;
  border-radius: 4px;
  background: #35432a;
  color: var(--lime);
  font-size: 11px;
}

#modal .sk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

#modal .sk {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 7px 10px;
  padding: 12px;
  border: 1px solid #48583c;
  border-radius: 5px;
  background: #2b3526;
}

#modal .sk.none {
  opacity: 1;
  background: #252e22;
}

#modal .sk .ico {
  color: var(--lime);
  font-size: 23px;
  filter: saturate(.8);
}

#modal .sk b {
  font-size: 12px;
  color: var(--cream);
}

#modal .sk .val {
  font-size: 11px;
  line-height: 1.45;
  color: #b4c2a4;
}

#modal .sk .lv {
  color: var(--lime);
  font: 11px monospace;
}

#modal .pips {
  margin-top: 6px;
  gap: 3px;
}

#modal .pip {
  width: 16px;
  max-width: 12%;
  height: 4px;
  border-radius: 1px;
  background: #ffffff18;
}

#modal .pip.on {
  background: var(--lime);
}

#modal .sk.maxed {
  border-color: #8c9f60;
  background: #344229;
}

#modal .sk.maxed .lv {
  color: var(--orange);
}

/* Pausa: paleta padrão dos modais, com retorno destacado e saída separada. */
#pause .card {
  position: relative;
  width: min(94vw, 510px);
  padding: 36px;
  border: 1px solid #64764e;
  border-radius: 12px;
  background: #222b21;
  box-shadow: 0 24px 100px #0008;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.pause-mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  color: var(--lime);
  background: #d6f2660b;
  border: 1px solid #7e915d;
  border-radius: 50%;
  font-size: 36px;
  font-weight: 900;
}

.overlay-kicker {
  color: var(--orange);
  font: 9px monospace;
  letter-spacing: 3px;
}

#pause #pause-title {
  margin: 0;
  text-transform: uppercase;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -2px;
  font-weight: 900;
}

#pause #pause-caption {
  margin: 0;
  color: #b0bfa1;
  font-size: 12px;
  line-height: 1.6;
}

#pause #pause-note {
  color: #ffbc96;
  padding: 10px 12px;
  margin: 0;
  border: 1px solid #ae774c;
  border-radius: 4px;
  background: #ff824c0a;
  font-size: 12px;
  text-align: center;
}

#pause .row {
  width: 100%;
  margin-top: 8px;
  gap: 10px;
}

#pause .row .btn {
  flex: 1;
  min-width: 0;
  min-height: 44px;
}

#pause .pause-actions { display: grid; grid-template-columns: 1fr 1fr; }
#pause #btn-resume { grid-column: 1 / -1; }
#pause #btn-pause-controls { grid-column: 1; grid-row: 2; }
#pause #btn-quit { grid-column: 2; grid-row: 2; }
#pause #btn-dev:not(.hidden) { grid-column: 1 / -1; grid-row: 3; }

@media (max-height:520px) {

  #modal,
  #pause {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  #modal .modal-box {
    padding: 16px 20px;
    gap: 12px;
    width: min(94vw, 590px);
  }

  #modal .modal-box.wide {
    width: min(100%, 920px);
  }

  #modal #modal-title {
    font-size: 22px;
  }

  #modal #modal-x {
    top: 10px;
    right: 12px;
  }

  .modal-masthead {
    font-size: 7px;
    letter-spacing: 1px;
  }

  .modal-footer {
    padding-top: 9px;
  }

  #modal .btn {
    min-height: 32px;
    padding: 7px 12px;
    font-size: 11px;
  }

  #modal .modal-lead {
    font-size: 11px;
    margin-bottom: 12px;
  }

  #modal #modal-body>label {
    min-height: 42px;
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 11px;
  }

  #modal table.stats td {
    padding: 7px 2px;
  }

  .profile-banner {
    padding: 11px;
    margin-bottom: 9px;
  }

  .profile-banner b {
    font-size: 18px;
  }

  #modal .cd {
    padding: 11px;
  }

  #modal .sk {
    padding: 10px;
  }

  #modal .sk-head {
    padding: 8px 10px;
    margin-bottom: 9px;
  }

  #pause .card {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 9px 20px;
    width: min(92vw, 560px);
    padding: 24px;
    text-align: left;
  }

  .pause-mark {
    grid-column: 1;
    grid-row: 1 / 4;
    width: 64px;
    height: 64px;
  }

  #pause .overlay-kicker,
  #pause #pause-title,
  #pause #pause-caption {
    grid-column: 2;
  }

  #pause #pause-title {
    font-size: 34px;
  }

  #pause #pause-caption {
    font-size: 11px;
  }

  #pause #pause-note {
    grid-column: 1 / -1;
    font-size: 11px;
  }

  #pause .row {
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    margin-top: 9px;
  }

  #pause .row .btn {
    min-height: 38px;
    font-size: 12px;
  }
}

@media (max-width:650px) {
  #modal .cdgrid {
    grid-template-columns: 1fr;
  }

  #modal .sk-grid {
    grid-template-columns: 1fr;
  }

  #modal #modal-title {
    font-size: 21px;
  }

  #modal .modal-box {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-masthead {
    font-size: 6px;
  }

  .modal-footer>small {
    font-size: 6px;
    letter-spacing: .8px;
  }

  .profile-banner>span {
    font-size: 9px;
  }

  #modal ol.rank li {
    gap: 10px;
    font-size: 11px;
  }

  #modal ol.rank b {
    font-size: 10px;
  }

  #modal .stat {
    grid-template-columns: 64px 1fr 42px;
    font-size: 11px;
  }

  #pause .card {
    padding: 22px;
  }
}

@media (prefers-reduced-motion:reduce) {

  #modal *,
  #pause * {
    transition: none !important;
  }
}

/* Classificação da partida: todos os jogadores, com rolagem no celular. */
.match-ranking {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.match-ranking thead th {
  padding: 7px 8px;
  color: #a3ad99;
  font-size: 9px;
  font-weight: 600;
  text-align: right;
}

.match-ranking thead th:nth-child(2) {
  text-align: left;
}

.match-ranking tbody th,
.match-ranking td {
  padding: 10px 8px;
  border-top: 1px solid #ffffff15;
  text-align: right;
}

.match-ranking tbody th {
  text-align: left;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.match-ranking td:first-child {
  color: #a3ad99;
  width: 28px;
}

.match-ranking td:last-child {
  color: #d6f266;
  font-weight: 750;
}

.match-ranking .me {
  background: #d6f26610;
  color: #d6f266;
}

.match-ranking small {
  font: 7px monospace;
  margin-left: 5px;
  color: #d6f266;
  white-space: nowrap;
}

@media (max-height:520px) {
  .match-ranking {
    font-size: 11px;
  }

  .match-ranking tbody th,
  .match-ranking td {
    padding: 7px 6px;
  }
}

/* Seleção: só nome e arte. As explicações e animações ficam no botão de informação. */
#modal .modal-box.mode-selection {
  width: min(100%, 760px);
}

#modal .mode-selection #modal-body {
  padding-right: 0;
}

#modal .mode-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#modal .mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: #252e23;
  border: 1px solid #48563d;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}

#modal .mode-card:has(.mode-pick:hover),
#modal .mode-card:has(.mode-pick:focus-visible) {
  border-color: var(--lime);
  background: #2e3a29;
}

#modal .mode-card.sel {
  border-color: #93a663;
}

#modal .mode-title {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin: 0;
  color: var(--cream);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -.4px;
  line-height: 1.2;
  pointer-events: none;
}

#modal .mode-stage {
  display: grid;
  place-items: center;
  height: clamp(66px, calc(100svh - 285px), 240px);
  border: 1px solid #3d4b34;
  border-radius: 5px;
  background: radial-gradient(ellipse at 50% 55%, #35442a55, transparent 70%), #1c251a;
  overflow: hidden;
  pointer-events: none;
}

#modal .mode-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

#modal .mode-pick {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  z-index: 2;
  cursor: pointer;
  border-radius: 6px;
}

#modal .mode-pick:focus-visible {
  outline-offset: -4px;
}

/* A informação mantém ícone e nome visíveis também ao lado do atalho do controle. */
#modal .mode-card .info {
  position: relative;
  align-self: flex-end;
  min-height: 32px;
  padding: 6px 10px;
  margin: 0;
  color: #c9d6bc;
  background: #303c29;
  border: 1px solid #58694a;
  border-radius: 5px;
  z-index: 3;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  font: 700 12px system-ui, sans-serif;
  cursor: pointer;
}

#modal .mode-card .info .ui-icon {
  width: 15px;
  height: 15px;
}

#modal .mode-card .info:hover {
  color: var(--lime);
  background: #ffffff15;
}

#modal .mode-demo-stage {
  position: relative;
  width: 100%;
  height: 192px;
  border-radius: 5px;
  background: #141b13;
  border: 1px solid #46553b;
  overflow: hidden;
}

#modal .mode-demo-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#modal .mode-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 9px;
}

#modal .mode-steps.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#modal .mode-step-btn {
  min-height: 30px;
  padding: 5px 6px;
  border: 1px solid #47563c;
  border-radius: 4px;
  background: #1f271d;
  color: #a8b69b;
  font: 700 9px monospace;
  letter-spacing: .2px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .15s;
}

#modal .mode-step-btn:hover {
  border-color: var(--lime);
  color: var(--cream);
  background: #2b3626;
}

#modal .mode-step-btn.active {
  background: var(--lime);
  color: #1d2618;
  border-color: var(--lime);
  font-weight: 850;
}

#modal .mode-demo-caption {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 4px;
  background: #1d251b;
  border: 1px solid #435238;
  color: var(--cream);
  font-size: 11.5px;
  line-height: 1.45;
  min-height: 42px;
  display: flex;
  align-items: center;
}

#modal .mode-detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

#modal .mode-detail-actions #md-play {
  flex: 1;
  min-height: 40px;
}

@media (max-width:650px) {
  #modal .mode-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width:480px) and (orientation:portrait) {
  #modal .mode-cards {
    grid-template-columns: 1fr;
  }

  #modal .mode-stage {
    height: 150px;
  }
}

@media (max-height:520px) {
  #modal .mode-demo-stage {
    height: 146px;
  }

  #modal .mode-cards {
    gap: 12px;
  }

  #modal .mode-card {
    padding: 8px;
    gap: 6px;
  }

  #modal .mode-stage {
    min-height: 52px;
    height: clamp(52px, calc(100svh - 285px), 240px);
  }

  #modal .mode-title {
    min-height: 26px;
    font-size: 15px;
    letter-spacing: -.3px;
  }
}

/* Painel de desenvolvimento: cabeçalho e rodapé fixos do modal, conteúdo rolável. */
#modal .dev-panel {
  display: grid;
  gap: 8px;
}

#modal .dev-panel p {
  margin: 0;
}

#modal .dev-targets,
#modal .dev-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

#modal .dev-targets>b {
  margin-right: 4px;
}

#modal #dev-status {
  padding: 8px 10px;
  border-left: 3px solid var(--lime);
  background: #d6f2660b;
  color: var(--cream);
  font-size: 12px;
}

#modal #dev-status:empty {
  display: none;
}

#modal .dev-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#modal .dev-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #48543d;
  border-radius: 5px;
  background: #252e23;
}

#modal .dev-section h3 {
  margin: 0;
  color: var(--lime);
  font-size: 14px;
}

#modal .dev-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

#modal .dev-panel input[type=number] {
  width: 76px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid #657452;
  border-radius: 4px;
  background: #182017;
  color: var(--cream);
  font: 600 16px system-ui, sans-serif;
}

#modal .dev-panel .dev-check {
  position: relative;
  padding-left: 27px;
  min-height: 30px;
  display: flex;
  align-items: center;
}

#modal .dev-panel .dev-check input {
  left: 0;
}

#modal .dev-skills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#modal .dev-skill {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
  font-size: 12px;
}

#modal .dev-skill small {
  color: var(--muted);
  font-size: 10px;
}

#modal .dev-skill input {
  grid-column: 1 / -1;
  width: 100%;
}

#modal .dev-bot-list {
  display: grid;
  gap: 5px;
}

#modal .dev-bot-list>div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #ffffff12;
  padding-top: 5px;
}

#modal .dev-bot-list span {
  overflow-wrap: anywhere;
  min-width: 0;
}

@media (max-width:650px) {
  #modal .dev-columns {
    grid-template-columns: 1fr;
  }
}

/* Cabe também em 568×320 com as ferramentas de desenvolvedor visíveis. */
@media (max-height:360px) {
  #pause .card { padding:16px 20px; gap:7px 16px; grid-template-columns:56px 1fr; }
  #pause .pause-mark { width:54px; height:54px; font-size:30px; }
  #pause #pause-title { font-size:30px; }
  #pause #pause-caption { font-size:10px; }
  #pause #pause-note { padding:8px 10px; font-size:10px; line-height:1.4; }
  #pause .row { margin-top:4px; gap:8px; }
  #pause .row .btn { min-height:34px; padding:7px 12px; font-size:11px; }
}
