/* =====================================================================
   DAMAS — Clássico Pixel
   Estilo pixel art: bordas duras, sombras deslocadas, sem dependências.
   ===================================================================== */

:root {
  --bg: #12100d;
  --bg-2: #1a1510;
  --panel: #241b14;
  --panel-2: #2f231a;
  --panel-3: #3a2b1f;
  --line: #553d29;
  --line-soft: #3d2c1e;
  --cream: #f2e3c6;
  --text: #e9d9bd;
  --muted: #a68a6a;
  --gold: #f0b429;
  --gold-dark: #a9741a;
  --red: #d64545;
  --red-dark: #8e2118;
  --green: #74b64a;
  --danger: #d1495b;
  --shadow: 0 4px 0 #0a0806;
  --anim: 200ms;
  --radius: 4px;
  --font: "Courier New", "Lucida Console", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(circle at 50% -10%, #2a2016 0%, rgba(18, 16, 13, 0) 60%),
    repeating-linear-gradient(0deg, #12100d 0 3px, #14110e 3px 6px);
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  font-size: 14px;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

h1, h2, h3, p { margin: 0; }

/* ------------------------------ VIEWS ------------------------------ */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; }

/* ------------------------------ MENU ------------------------------- */
#view-menu {
  position: relative;
  align-items: center;
  padding: 14px 16px 22px;
  overflow: hidden;
}

.menu-sky {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, rgba(240, 180, 41, .08) 0%, rgba(240, 180, 41, 0) 45%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .022) 0 2px, rgba(0, 0, 0, 0) 2px 6px);
  pointer-events: none;
}

.menu-top {
  position: relative;
  width: 100%;
  max-width: 880px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 8px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 #0a0806;
  text-align: left;
  transition: transform .08s;
}
.profile-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0806; }

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #6d3b23, #3d2114);
  border: 2px solid var(--gold-dark);
  border-radius: 3px;
  font-size: 20px;
  color: var(--gold);
}

.profile-chip-text { display: flex; flex-direction: column; gap: 3px; min-width: 96px; }
.profile-chip-text strong { font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
.profile-chip-text small { color: var(--muted); font-size: 10px; letter-spacing: .6px; }

.mini-xp {
  display: block;
  height: 6px;
  background: #100d0a;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.mini-xp i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), #ffd873); }

.top-right { display: flex; align-items: center; gap: 8px; }

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 #0a0806;
  font-size: 13px;
}
.coin-pill.small { padding: 5px 9px; font-size: 12px; }
.coin { color: var(--gold); font-size: 14px; text-shadow: 0 0 6px rgba(240, 180, 41, .5); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 #0a0806;
  font-size: 15px;
  color: var(--cream);
  transition: transform .08s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0806; }

.logo {
  position: relative;
  text-align: center;
  margin: 22px 0 20px;
}
.logo h1 {
  font-size: clamp(38px, 12vw, 68px);
  letter-spacing: clamp(4px, 2.4vw, 12px);
  color: var(--cream);
  text-shadow:
    0 4px 0 #6b3418,
    0 8px 0 #2a170d,
    0 0 26px rgba(240, 180, 41, .22);
}
.logo p {
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(10px, 2.6vw, 13px);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.logo-pieces { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.logo-pieces .lp {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-block;
  border: 2px solid #1a120c;
}
.logo-pieces .lp.red { background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--red) 55%, var(--red-dark)); }
.logo-pieces .lp.black { background: radial-gradient(circle at 35% 30%, #6a625c, #2a2623 55%, #100d0b); }

.menu-grid {
  position: relative;
  width: 100%;
  max-width: 880px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 620px) {
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-desc { display: none; }
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 #0a0806, inset 0 1px 0 rgba(255, 255, 255, .05);
  text-align: left;
  min-height: 84px;
  transition: transform .07s, border-color .12s;
}
.tile:hover { border-color: var(--gold-dark); }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #0a0806; }
.tile-icon {
  font-size: 20px;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 2px 0 #3a2408;
}
.tile-title { font-size: 13px; font-weight: bold; letter-spacing: .6px; text-transform: uppercase; color: var(--cream); }
.tile-desc { font-size: 10px; color: var(--muted); letter-spacing: .4px; }

.menu-foot { margin-top: auto; padding-top: 22px; color: #6f5a44; font-size: 10px; letter-spacing: 1px; text-align: center; }

/* ------------------------------ JOGO ------------------------------- */
#view-game { padding: 10px 12px 18px; gap: 10px; }

.game-top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}
.game-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.game-title strong {
  font-size: 13px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-title span { font-size: 10px; color: var(--muted); letter-spacing: .8px; }
.game-top-actions { display: flex; gap: 8px; }

.game-area {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 16px;
  align-items: start;
}

.board-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--panel);
  border: 2px solid var(--line-soft);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.player-strip.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(240, 180, 41, .25), 0 3px 0 #0a0806; }
.strip-avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 15px;
  border: 2px solid #100d0b;
  flex: 0 0 auto;
}
.strip-avatar.red { background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--red) 55%, var(--red-dark)); color: #fff3ee; }
.strip-avatar.black { background: radial-gradient(circle at 35% 30%, #6a625c, #2a2623 55%, #100d0b); color: #e6ddd2; }
.strip-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.strip-info strong { font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--cream); }
.strip-info small { font-size: 10px; color: var(--muted); }
.strip-turn { font-size: 10px; letter-spacing: 1px; color: var(--gold); text-transform: uppercase; }

.board-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.board {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 6px solid #4a2c19;
  box-shadow:
    0 0 0 3px #1b1008,
    0 10px 0 #150e08,
    0 12px 22px rgba(0, 0, 0, .55);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.sq { position: relative; }
.sq.light { background: #d9a86b; }
.sq.dark { background: #8b4a2b; }

/* textura de madeira */
.theme-wood .sq.light {
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, rgba(255,255,255,.05) 2px 5px),
    #d9a86b;
}
.theme-wood .sq.dark {
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.09) 0 2px, rgba(255,255,255,.03) 2px 6px),
    #7d4024;
}
.theme-marble .sq.light { background: repeating-linear-gradient(45deg, #e4e0d4 0 6px, #dbd6c8 6px 12px); }
.theme-marble .sq.dark { background: repeating-linear-gradient(45deg, #5b6472 0 6px, #525a67 6px 12px); }
.theme-night .sq.light { background: linear-gradient(160deg, #2c4e6b, #233d55); }
.theme-night .sq.dark { background: linear-gradient(160deg, #15283b, #101e2d); }
.theme-retro .sq.light { background: repeating-linear-gradient(0deg, #a3cc4f 0 5px, #98c147 5px 10px); }
.theme-retro .sq.dark { background: repeating-linear-gradient(0deg, #2f6b3a 0 5px, #2a5f34 5px 10px); }

/* destaques das casas */
.sq::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.sq.last::after { background: rgba(240, 180, 41, .16); box-shadow: inset 0 0 0 2px rgba(240, 180, 41, .5); }
.sq.sel::after { box-shadow: inset 0 0 0 4px var(--gold); background: rgba(240, 180, 41, .18); }
.sq.hint::after {
  background: radial-gradient(circle, rgba(116, 182, 74, .95) 0 22%, rgba(116, 182, 74, 0) 24%);
}
.sq.hint-cap::after {
  box-shadow: inset 0 0 0 4px rgba(209, 73, 91, .9);
  background: rgba(209, 73, 91, .18);
}
.sq.check::after { box-shadow: inset 0 0 0 4px rgba(209, 73, 91, .85); }
.sq.movable::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(255, 246, 222, .22);
  border-radius: 3px;
  pointer-events: none;
}
.sq.sel::before, .sq.hint::before { display: none; }

.pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  transform: translate3d(calc(var(--c, 0) * 100%), calc(var(--r, 0) * 100%), 0);
  transition: transform var(--anim) cubic-bezier(.3, 1.25, .5, 1);
  will-change: transform;
  z-index: 2;
}
.piece.spawn { animation: pop .18s ease-out; }
@keyframes pop { from { transform: translate3d(calc(var(--c, 0) * 100%), calc(var(--r, 0) * 100%), 0) scale(.6); opacity: .4; } }

.piece-body {
  position: relative;
  width: 84%;
  height: 84%;
  margin: 8%;
  border-radius: 50%;
  transition: opacity calc(var(--anim) * .8) ease, transform calc(var(--anim) * .8) ease;
  display: grid;
  place-items: center;
}

.piece.red .piece-body {
  background:
    radial-gradient(circle at 34% 26%, #ff9c8c 0%, #e2564a 38%, #a8241a 74%, #6d130c 100%);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .35),
    inset 0 3px 0 rgba(255, 255, 255, .22),
    0 3px 0 rgba(0, 0, 0, .45);
  border: 2px solid #5c1109;
}
.piece.black .piece-body {
  background:
    radial-gradient(circle at 34% 26%, #7c736c 0%, #423b36 38%, #26211e 74%, #0d0b0a 100%);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, .5),
    inset 0 3px 0 rgba(255, 255, 255, .14),
    0 3px 0 rgba(0, 0, 0, .5);
  border: 2px solid #050404;
}

.piece-ridge {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .18);
  pointer-events: none;
}
.piece.black .piece-ridge { border-color: rgba(255, 255, 255, .1); }

.crown {
  position: relative;
  color: var(--gold);
  font-size: calc(var(--cell, 52px) * 0.5);
  line-height: 1;
  opacity: 0;
  transform: scale(.4) rotate(-12deg);
  transition: opacity .2s ease, transform .25s cubic-bezier(.3, 1.6, .5, 1);
  text-shadow: 0 1px 0 #4a2c05, 0 0 6px rgba(240, 180, 41, .6);
  pointer-events: none;
}
.piece.king .crown { opacity: 1; transform: scale(1) rotate(0); }
.piece.king .piece-body { box-shadow: inset 0 -4px 0 rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.25), 0 0 0 2px rgba(240, 180, 41, .55), 0 3px 0 rgba(0,0,0,.45); }

.piece.gone { z-index: 1; pointer-events: none; }
.piece.gone .piece-body { opacity: 0; transform: scale(.35) rotate(25deg); }

.pieces-neon .piece.red .piece-body { box-shadow: 0 0 10px rgba(255, 80, 70, .85), inset 0 -4px 0 rgba(0,0,0,.35), 0 3px 0 rgba(0,0,0,.4); }
.pieces-neon .piece.black .piece-body { box-shadow: 0 0 10px rgba(120, 200, 255, .55), inset 0 -3px 0 rgba(0,0,0,.4), 0 3px 0 rgba(0,0,0,.4); }
.pieces-gold .piece-body { border-color: var(--gold); }
.pieces-gold .piece.black .piece-body { border-color: #caa04a; }

.board-overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 6, .72);
  backdrop-filter: blur(2px);
  border-radius: 4px;
  z-index: 5;
  font-size: clamp(14px, 4vw, 22px);
  letter-spacing: 4px;
  color: var(--gold);
  text-align: center;
  padding: 10px;
}

.game-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 12px;
  letter-spacing: .8px;
  text-transform: uppercase;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 4px 0 #0a0806;
  color: var(--cream);
  transition: transform .07s;
  white-space: nowrap;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0a0806; }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 #0a0806; }
.btn.primary { background: linear-gradient(180deg, #f0b429, #c98a13); color: #2a1a05; border-color: #7d5508; font-weight: bold; }
.btn.danger { background: linear-gradient(180deg, #d1495b, #9b2c3a); border-color: #5f1a23; color: #fff; }
.btn.ghost { background: linear-gradient(180deg, var(--panel-2), var(--panel)); }

/* painel lateral */
.info-col { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 3px 0 #0a0806;
}
.turn-card { display: flex; align-items: center; gap: 10px; }
.turn-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red);
  border: 2px solid #100d0b;
  box-shadow: 0 0 10px rgba(214, 69, 69, .6);
  flex: 0 0 auto;
}
.turn-dot.black { background: #2a2623; box-shadow: 0 0 10px rgba(120, 120, 120, .5); }
.turn-card strong { display: block; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--cream); }
.turn-card small { font-size: 10px; color: var(--muted); }

.score-card { display: flex; flex-direction: column; gap: 6px; }
.score-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: .6px; }
.score-label { color: var(--muted); text-transform: uppercase; }
.score-values { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.score-values i { color: #6f5a44; font-style: normal; font-size: 10px; }
.txt-red { color: #ff8d80; }
.txt-black { color: #cfc6ba; }

.log-card { flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.card-head h3 { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--cream); }
.card-head span { font-size: 10px; color: var(--muted); }
.move-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  font-size: 11px;
  scrollbar-width: thin;
}
.move-log li { color: var(--muted); display: flex; gap: 6px; }
.move-log li b { color: var(--cream); font-weight: normal; }
.move-log li.capture b { color: #ffb3a8; }
.move-log li .ply { color: #6f5a44; min-width: 20px; }

@media (min-width: 881px) {
  .board-shell { width: min(560px, calc(100vh - 300px)); }
  .player-strip, .game-controls { max-width: min(560px, calc(100vh - 300px)); }
}

@media (max-width: 880px) {
  .game-area { grid-template-columns: minmax(0, 1fr); }
  .info-col { order: 2; }
  .log-card { min-height: 0; }
  .move-log { max-height: 120px; }
}
@media (max-width: 520px) {
  #view-game { padding: 8px 8px 16px; }
  .game-controls .btn { font-size: 11px; padding: 9px 8px; letter-spacing: .4px; }
  .player-strip { padding: 6px 8px; }
  .strip-avatar { width: 26px; height: 26px; font-size: 13px; }
}

/* ------------------------------ PAINÉIS ---------------------------- */
#view-panel { padding: 0 0 30px; }
.page-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #1a1510, rgba(26, 21, 16, .94));
  border-bottom: 2px solid var(--line);
}
.page-top h2 {
  flex: 1;
  font-size: 14px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--cream);
}
.panel-body {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 6px;
}
.muted { color: var(--muted); }
.small { font-size: 11px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-box {
  background: var(--panel);
  border: 2px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}
.stat-box b { display: block; font-size: 18px; color: var(--cream); }
.stat-box span { font-size: 9px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }

.big-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 3px 0 #0a0806;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title strong { font-size: 12px; color: var(--cream); }
.row-title small { font-size: 10px; color: var(--muted); }

.bar { height: 8px; background: #100d0a; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffd873); }

.badge {
  font-size: 9px;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.on { color: #0f1a08; background: var(--green); border-color: #4c8129; }
.badge.gold { color: #241703; background: var(--gold); border-color: #a9741a; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 10px;
  letter-spacing: .6px;
  padding: 4px 8px;
  background: #1c150f;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--muted);
}
.chip.win { color: #b4e18c; border-color: #47692f; }
.chip.loss { color: #ff9d94; border-color: #6c2b27; }
.chip.draw { color: #d8c78d; border-color: #6a5a2c; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 11px;
}
.history-item:last-child { border-bottom: 0; }
.history-item .h-main { display: flex; flex-direction: column; gap: 2px; }
.history-item small { color: var(--muted); font-size: 10px; }

.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .shop-grid { grid-template-columns: minmax(0, 1fr); } }

.shop-item { display: flex; flex-direction: column; gap: 8px; }
.shop-preview {
  height: 64px;
  border-radius: 3px;
  border: 2px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  overflow: hidden;
}
.shop-preview span { display: block; }
.shop-preview .pl { background: #d9a86b; }
.shop-preview .pd { background: #7d4024; }
.shop-preview.theme-marble .pl { background: #e4e0d4; }
.shop-preview.theme-marble .pd { background: #5b6472; }
.shop-preview.theme-night .pl { background: #2c4e6b; }
.shop-preview.theme-night .pd { background: #15283b; }
.shop-preview.theme-retro .pl { background: #a3cc4f; }
.shop-preview.theme-retro .pd { background: #2f6b3a; }

.rank-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12px;
}
.rank-row.you { background: rgba(240, 180, 41, .1); border: 2px solid var(--gold-dark); border-radius: 3px; }
.rank-pos { color: var(--gold); text-align: center; font-size: 11px; }
.rank-name { color: var(--cream); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: var(--muted); font-size: 11px; text-align: right; }
.rank-score b { color: var(--cream); display: block; font-size: 13px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .row-title strong { font-size: 12px; }

.switch {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 3px;
  background: #100d0a;
  border: 2px solid var(--line);
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #6f5a44;
  border-radius: 2px;
  transition: transform .15s, background .15s;
}
.switch.on { border-color: var(--gold-dark); }
.switch.on::after { transform: translateX(22px); background: var(--gold); }

.select {
  background: #100d0a;
  border: 2px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
}

.rule-list { display: flex; flex-direction: column; gap: 8px; font-size: 12px; line-height: 1.55; color: var(--text); }
.rule-list b { color: var(--gold); }

.input {
  background: #100d0a;
  border: 2px solid var(--line);
  color: var(--text);
  padding: 10px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

/* ------------------------------ MODAL / TOAST ---------------------- */
.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, .78);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 90;
}
.modal-wrap.hidden { display: none; }
.modal {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #2c2118, #201811);
  border: 3px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 8px 0 #080605, 0 18px 34px rgba(0, 0, 0, .6);
  padding: 16px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal h3 {
  font-size: 14px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.modal-body { font-size: 12px; line-height: 1.6; color: var(--text); }
.modal-body p { margin-bottom: 8px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.modal-actions .btn { white-space: normal; line-height: 1.35; text-align: center; }

.result-line { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line-soft); font-size: 12px; }
.result-line span { color: var(--muted); }
.result-line b { color: var(--cream); }
.result-big { font-size: 22px; letter-spacing: 2px; text-align: center; margin-bottom: 6px; }
.result-big.win { color: var(--gold); }
.result-big.loss { color: #ff8d80; }
.result-big.draw { color: #cdbb8a; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 120;
  width: min(92vw, 380px);
  pointer-events: none;
}
.toast {
  background: #241b14;
  border: 2px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 3px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 4px 0 #0a0806;
  animation: toastIn .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.hidden { display: none !important; }

/* respeita usuários que preferem menos animação */
@media (prefers-reduced-motion: reduce) {
  :root { --anim: 0ms; }
  .piece, .piece-body, .crown { transition: none !important; }
  .piece.spawn { animation: none; }
  .toast { animation: none; }
}

/* ---------- Online (salas por código) ---------- */
.room-code {
  font-family: "Courier New", monospace;
  font-size: 34px;
  font-weight: bold;
  letter-spacing: .16em;
  text-align: center;
  color: var(--gold);
  padding: 8px 0 4px;
}
.code-input {
  text-transform: uppercase;
  letter-spacing: .28em;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
}
.online-room .btn { width: 100%; margin-top: 8px; }
.txt-green { color: var(--green); }

/* ---------- Mensagens rápidas na partida online ---------- */
.quick-chat {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px;
  background: var(--panel);
  border: 2px solid var(--line-soft);
  border-radius: var(--radius);
}
.quick-chat-status {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .3px;
  color: var(--gold);
}
.quick-chat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-chip {
  flex: 1 1 auto;
  min-height: 36px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: .3px;
  color: var(--cream);
  background: #1d1815;
  border: 2px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.quick-chip:active { transform: translateY(1px); background: #2a231e; border-color: var(--gold); }

/* ---------- Botão Instalar app (só quando o celular permite) ---------- */
.install-app {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 0 16px;
  letter-spacing: .5px;
}
