/* Telas da fatia (h): menu, Acervo com busca e filtros, Decks, editor de deck, Como jogar e as folhas
   (filtros, exportar/importar). Reaproveita os botões de pedra e as cartas de screens.css e match.css. As
   telas rolam com rolagem nativa (touch-action: pan-y), porque a página bloqueia o gesto para a partida. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Campos de texto: a partida bloqueia a seleção, aqui o jogador precisa digitar e selecionar o código. */
.game input,
.game textarea,
.game select {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

/* ------------------------------------------------------------------ menu */
.home {
  overflow-y: auto;
  touch-action: pan-y;
}

.home-card {
  margin: auto;
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 14px;
  row-gap: 0;
}

/* O menu cresceu (7 botões): em tela baixa ele rola em vez de cortar o fim. */
.home {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.link-btn {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: #c9b6ff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  touch-action: manipulation;
}

.link-btn:focus-visible {
  outline: 2px solid #c9a8ff;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ páginas que rolam (Decks, Como jogar) */
.page-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.page-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 12px 16px max(28px, env(safe-area-inset-bottom));
}

.notice {
  padding: 10px 12px;
  border: 2px solid #a8505c;
  border-radius: 12px;
  background: rgba(116, 48, 61, 0.55);
  color: #ffe1e4;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 6px;
}

.deck-section {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  line-height: 1.1;
  -webkit-text-stroke: 3px var(--outline);
  paint-order: stroke fill;
}

.deck-section small {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  -webkit-text-stroke: 0;
}

.decks-actions {
  display: flex;
  gap: 10px;
}

.decks-actions .big-btn {
  flex: 1 1 0;
  min-height: 52px;
  font-size: 20px;
}

.decks-status {
  margin: 0;
  color: #cdb8ff;
  font-size: 13px;
  font-weight: 700;
}

.decks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.decks-empty,
.deck-empty {
  margin: 0;
  color: #c9bfe6;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.deck-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 12px;
  border: 3px solid var(--outline);
  border-radius: 16px;
  background: linear-gradient(#3a3356, #231e3a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12), 0 4px 0 #0c0a16;
}

.deck-item.is-ready {
  background: linear-gradient(#2f3656, #1f2438);
}

.deck-item-status {
  margin: 0;
  color: #bfb5de;
  font-size: 12px;
  font-weight: 600;
}

.deck-item-status.is-warn {
  color: #ffc9a8;
}

.deck-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.act-btn.deck-act {
  flex: 1 1 0;
  min-width: 74px;
  height: 44px;
  font-size: 15px;
}

.act-btn.deck-act--danger {
  background: linear-gradient(#a8505c, #74303d);
}

.deck-section-title,
.deck-list .deck-section:first-child {
  margin-top: 0;
}

/* ------------------------------------------------------------------ Acervo: busca, filtros, grade */
.browser-host {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.browser {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.browser-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 8px 16px 0;
}

.search-box {
  flex: 1 1 auto;
  min-width: 0;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: #231e3a;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--font-ui);
  /* 16 px: o Chrome não dá zoom no campo ao focar. */
  font-size: 16px;
  font-weight: 600;
}

.search-input::placeholder {
  color: #8f86b3;
}

.search-input:focus-visible {
  outline: 3px solid #d9c6ff;
  outline-offset: 1px;
}

.act-btn.filter-btn {
  flex: 0 0 auto;
  min-width: 92px;
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
}

.act-btn.filter-btn.is-active {
  background: linear-gradient(#8f63f7, #5d34c4);
  box-shadow: 0 0 0 2px #d9c6ff, 0 3px 0 #120e1f;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 11px;
  background: #fff;
  color: #3b2a7a;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
}

.browser-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  width: min(1000px, 100%);
  min-height: 34px;
  margin: 0 auto;
  padding: 0 16px;
}

.browser-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.browser-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.browser-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 16px;
  color: #c9bfe6;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.browser-empty p {
  margin: 0;
}

.browser-empty .big-btn {
  width: min(260px, 100%);
}

/* Carta do deck, na grade do editor: borda verde e selo de marcado. */
.card--tile.is-picked {
  box-shadow: 0 0 0 3px #4ade80, 0 3px 0 #0c0a16;
}

.card--tile.is-picked::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border: 2px solid var(--outline);
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M5.5 11.5l3.6 3.6 7.4-8' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat,
    #2fb866;
  pointer-events: none;
}

/* ------------------------------------------------------------------ folhas */
.sheet--bottom {
  align-items: flex-end;
  padding: 0;
}

.sheet-panel,
.sheet--filters .sheet-card {
  padding: 14px 14px 12px;
  border: 3px solid var(--outline);
  background: linear-gradient(#3a3356, #231e3a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12), 0 6px 0 #0c0a16, 0 0 50px rgba(124, 58, 237, 0.35);
}

.sheet-panel {
  border-radius: 18px;
  overflow-y: auto;
  touch-action: pan-y;
}

.sheet--filters .sheet-card {
  width: min(600px, 100%);
  max-height: 88%;
  gap: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
}

.filters-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  padding-bottom: 8px;
}

.filters-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  line-height: 1.1;
  -webkit-text-stroke: 4px var(--outline);
  paint-order: stroke fill;
}

.filters-count {
  margin: 0;
  color: #d6ccf3;
  font-size: 14px;
  font-weight: 700;
}

.filters-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 2px 2px 8px;
}

.filters-foot {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  padding-top: 8px;
}

.filters-foot .big-btn {
  flex: 1 1 0;
  min-height: 52px;
  font-size: 19px;
}

.filters-foot .big-btn--primary {
  flex: 2 1 0;
}

.facet {
  min-width: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.facet legend {
  padding: 0;
  margin-bottom: 6px;
  color: #d6ccf3;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 3px solid var(--outline);
  border-radius: 22px;
  background: linear-gradient(#4a4466, #2f2a4a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12), 0 3px 0 #0c0a16;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.chip:active {
  transform: translateY(2px);
}

.chip:focus-visible {
  outline: 3px solid #d9c6ff;
  outline-offset: 2px;
}

.chip.is-on {
  background: linear-gradient(#a57bff, #6a3ae0 55%, #5527c0);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 0 0 2px #d9c6ff, 0 3px 0 #0c0a16;
}

.chip-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 2px solid var(--outline);
  border-radius: 3px;
  background: var(--domain, #8f9ab5);
  transform: rotate(45deg);
}

.sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.15;
  -webkit-text-stroke: 4px var(--outline);
  paint-order: stroke fill;
}

.sheet-text {
  margin: 0;
  color: #d6ccf3;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.sheet-error {
  margin: 0;
  color: #ffc9a8;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.code-box {
  width: 100%;
  padding: 10px 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: #171229;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4);
  color: #efe6ff;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.4;
  word-break: break-all;
  resize: none;
}

.code-box:focus-visible {
  outline: 3px solid #d9c6ff;
}

.sheet-panel .big-btn {
  min-height: 50px;
  font-size: 20px;
}

.sheet-pick {
  min-height: 48px;
  font-size: 20px;
}

/* ------------------------------------------------------------------ escolha do deck: deck do bot */
.botdeck-pick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.botdeck-select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: linear-gradient(#3a3356, #231e3a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12), 0 3px 0 #0c0a16;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  /* A lista aberta é nativa: sem isto, no desktop (Windows) ela sai com fundo branco e a letra clara. */
  color-scheme: dark;
}

.botdeck-select option,
.botdeck-select optgroup {
  background: #231e3a;
  color: var(--text);
}

.botdeck-select option:checked {
  background: #5d34c4;
  color: #fff;
}

#botdeck-note {
  margin: -4px 0 0;
  text-align: left;
}

.deck-list .deck-section:first-child {
  margin-top: 0;
}

/* ------------------------------------------------------------------ editor de deck */
.deck-name-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 4px;
  border: 0;
  border-bottom: 3px dashed #5b5280;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.3px;
  -webkit-text-stroke: 4px var(--outline);
  paint-order: stroke fill;
}

.deck-name-input:focus-visible {
  outline: none;
  border-bottom-color: #d9c6ff;
}

.editor-top {
  flex: 0 0 auto;
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 10px 16px 0;
}

.slots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 4px;
}

.slots.is-shaking {
  animation: slots-shake 0.32s ease;
}

@keyframes slots-shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.slot {
  position: relative;
  flex: 0 0 var(--slot-w, 36px);
  width: var(--slot-w, 36px);
  height: var(--slot-h, 46px);
  padding: 0;
  border: 2px dashed #5b5280;
  border-radius: 6px;
  background: #1c1530;
  color: #6e6496;
  cursor: pointer;
  touch-action: manipulation;
}

.slot:not(.is-filled)::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
}

.slot.is-filled {
  border: 0;
  box-shadow: 0 2px 0 #0c0a16;
}

.slot:disabled:not(.is-filled) {
  cursor: default;
}

.slot canvas {
  display: block;
  border-radius: 5px;
}

.slot:focus-visible {
  outline: 3px solid #d9c6ff;
  outline-offset: 2px;
}

.slot:active:not(:disabled) {
  transform: translateY(2px);
}

.editor-info {
  min-height: 56px;
  padding-top: 6px;
}

.editor-stats {
  margin: 0;
  color: #d6ccf3;
  font-size: 13px;
  font-weight: 700;
}

.editor-stats b {
  color: #fff;
}

.editor-message {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.editor-message[data-kind="warn"] {
  color: #ffc9a8;
}

.editor-message[data-kind="ok"] {
  color: #7be3a0;
}

/* ------------------------------------------------------------------ Como jogar */
.guide {
  gap: 4px;
}

.guide-block {
  padding: 4px 0 8px;
}

.guide-block p {
  margin: 6px 0 0;
  color: #e3defa;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
}

.guide-title {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
  -webkit-text-stroke: 4px var(--outline);
  paint-order: stroke fill;
}

.guide-glossary {
  margin: 10px 0 0;
}

.guide-glossary dt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 18px;
  -webkit-text-stroke: 3px var(--outline);
  paint-order: stroke fill;
}

.guide-glossary dd {
  margin: 2px 0 0 30px;
  color: #d6ccf3;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-height: 760px) {
  .home-card {
    gap: 7px;
  }

  .home-card .big-btn {
    min-height: 44px;
    font-size: 19px;
  }

  .home-card .big-btn--play {
    min-height: 54px;
    font-size: 26px;
  }

  .home .logo {
    font-size: clamp(44px, 13vw, 64px);
  }
}

@media (max-height: 680px) {
  .editor-info {
    min-height: 50px;
  }

  .browser-meta {
    min-height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slots.is-shaking {
    animation: none;
  }
}
