@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #0a1018;
  --bg-soft: #101a25;
  --panel: rgba(18, 30, 42, .88);
  --panel-solid: #142231;
  --panel-raised: #1a2b3b;
  --line: rgba(173, 198, 211, .16);
  --line-strong: rgba(173, 198, 211, .28);
  --text: #f5f7f4;
  --muted: #93a7b4;
  --subtle: #647b8a;
  --accent: #8ce0b6;
  --accent-strong: #51c78f;
  --warm: #f2c879;
  --danger: #f18b87;
  --light-square: #e5ded0;
  --dark-square: #496873;
  --shadow: 0 28px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(76, 143, 137, .22), transparent 31rem),
    radial-gradient(circle at 100% 88%, rgba(202, 149, 79, .12), transparent 28rem),
    var(--bg);
  font-family: 'DM Sans', sans-serif;
}
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { width: min(1240px, 100%); margin: 0 auto; padding: 34px 34px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 46px; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid rgba(140, 224, 182, .38); border-radius: 17px; color: var(--accent); background: linear-gradient(145deg, #183b3c, #10252f); box-shadow: 0 12px 30px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.1); font-size: 30px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.topbar h1 { margin: 0; color: var(--text); font: 700 26px/1 'Space Grotesk', sans-serif; letter-spacing: -.04em; }
.version-badge { display: inline-block; margin-left: 6px; padding: 4px 7px; border: 1px solid rgba(140,224,182,.45); border-radius: 7px; color: var(--accent); background: rgba(140,224,182,.1); font: 700 10px 'DM Sans', sans-serif; letter-spacing: .08em; vertical-align: middle; }
.topbar-meta { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(18,30,42,.62); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(140,224,182,.12); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 44px; align-items: start; }
.board-column { width: min(100%, 720px); margin: auto; }
.board-frame { padding: 15px; border: 1px solid var(--line-strong); border-radius: 26px; background: linear-gradient(145deg, rgba(36,57,69,.95), rgba(12,20,29,.96)); box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.08); }
.board-frame:focus-within { outline: 2px solid rgba(140,224,182,.7); outline-offset: 5px; }
#tabuleiro { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; overflow: hidden; border: 3px solid #172630; border-radius: 15px; box-shadow: 0 15px 38px rgba(0,0,0,.48); }
.casa { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; font-family: 'Times New Roman', serif; font-size: clamp(30px, 7.5vw, 74px); line-height: 1; transition: filter .16s, transform .16s; }
.casa::before { content: ''; position: absolute; inset: 0; pointer-events: none; }
.clara { background: var(--light-square); }
.escura { background: var(--dark-square); }
.casa:hover { filter: brightness(1.09) saturate(1.05); }
.casa:focus-visible { z-index: 8; outline: 4px solid #ffdc67; outline-offset: -5px; box-shadow: inset 0 0 0 3px #081016, 0 0 0 2px #fff; }
.casa .piece { position: relative; z-index: 2; filter: drop-shadow(0 4px 3px rgba(0,0,0,.35)); }
/* As peças mantêm a cor do lado em qualquer casa do tabuleiro. */
.piece--white { color: #fffdf6; text-shadow: 0 1px rgba(255,255,255,.9), 0 3px 2px rgba(0,0,0,.48); }
.piece--black { color: #18252b; text-shadow: 0 1px rgba(255,255,255,.25), 0 3px 2px rgba(0,0,0,.5); }
.casa::after { content: ''; position: absolute; z-index: 3; width: 18%; aspect-ratio: 1; border-radius: 50%; background: rgba(20,37,44,.55); transform: scale(0); transition: transform .15s; }
.casa.movimento::after { transform: scale(1); }
.casa.captura::after { width: 82%; background: transparent; border: 5px solid rgba(242,122,122,.76); transform: scale(1); }
.casa.selecionada::before { box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 34px rgba(140,224,182,.45); }
.casa.ultimo-lance::before { background: rgba(242,200,121,.25); }
.casa.em-xeque::before { background: radial-gradient(circle, rgba(238,94,94,.72), rgba(238,94,94,.12) 62%, transparent 75%); }
.coord-file, .coord-rank { position: absolute; z-index: 4; color: rgba(20,32,42,.58); font: 700 11px 'DM Sans', sans-serif; pointer-events: none; }
.escura .coord-file, .escura .coord-rank { color: rgba(239,255,255,.67); }
.coord-file { right: 6px; bottom: 4px; }
.coord-rank { left: 6px; top: 4px; }

.player-card { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; margin: 0 0 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(18,30,42,.72); box-shadow: 0 8px 20px rgba(0,0,0,.1); }
.player-card--bottom { margin: 13px 0 0; }
.player-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font: 25px 'Times New Roman', serif; }
.player-avatar--dark { color: #f2f5f2; background: #2b4650; }
.player-avatar--light { color: #17232a; background: var(--light-square); }
.player-details { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.player-details strong { font-size: 13px; }
.captured { min-height: 16px; color: #a5b5bd; font: 17px 'Times New Roman', serif; letter-spacing: -5px; white-space: nowrap; }
.player-side { color: var(--subtle); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.player-side--light { color: var(--accent); }

.side-panel { display: flex; flex-direction: column; gap: 14px; }
.status-card { display: flex; align-items: center; gap: 13px; min-height: 80px; padding: 15px 17px; border: 1px solid rgba(140,224,182,.28); border-radius: 18px; background: linear-gradient(135deg, rgba(27,67,61,.95), rgba(16,31,38,.95)); box-shadow: 0 14px 30px rgba(0,0,0,.17); }
.status-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: var(--accent); background: rgba(140,224,182,.13); font: 26px 'Times New Roman', serif; }
.status-copy { display: flex; flex-direction: column; gap: 4px; }
.status-copy small, .setting-row small, .section-heading small { color: #8ba4ae; font-size: 9px; font-weight: 700; letter-spacing: .15em; }
.status-copy strong { font: 600 17px 'Space Grotesk', sans-serif; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.control-button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 45px; border: 1px solid var(--line); border-radius: 12px; color: #cbd7dc; background: rgba(20,34,48,.8); cursor: pointer; font-size: 12px; font-weight: 600; transition: .18s; }
button:focus-visible { outline: 3px solid #ffdc67; outline-offset: 3px; box-shadow: 0 0 0 2px #081016; }
.control-button:hover { color: #fff; border-color: #668492; background: var(--panel-raised); transform: translateY(-2px); }
.control-button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.control-button span { color: var(--accent); font-size: 17px; }
.control-button--primary { border-color: rgba(140,224,182,.48); color: #e0fff1; background: #1d5148; }
.control-button--danger:hover { border-color: #a66565; background: #3a252c; }
.control-button--danger span { color: var(--danger); }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(20,34,48,.78); }
.setting-row div { display: flex; flex-direction: column; gap: 5px; }
.setting-row strong { color: #e4ecee; font-size: 14px; }
.round-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #486573; border-radius: 50%; color: var(--accent); background: #17313a; cursor: pointer; font-size: 19px; transition: transform .2s; }
.round-button:hover { transform: rotate(90deg); }
.moves-card { min-height: 294px; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(20,34,48,.78); }
.section-heading { display: flex; align-items: end; justify-content: space-between; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 4px 0 0; font: 600 17px 'Space Grotesk', sans-serif; }
.move-count { display: grid; place-items: center; min-width: 29px; height: 25px; border-radius: 8px; color: var(--accent); background: rgba(140,224,182,.12); font-size: 11px; font-weight: 700; }
.move-list { max-height: 235px; overflow: auto; padding-top: 5px; }
.move-list::-webkit-scrollbar { width: 5px; }
.move-list::-webkit-scrollbar-thumb { background: #45606d; border-radius: 99px; }
.move-row { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px; align-items: center; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,.06); color: #cbd7dc; font-size: 12px; }
.move-row:last-child { border-bottom: 0; }
.move-number { color: var(--subtle); }
.move-row .current { color: var(--accent); font-weight: 700; }
.empty-moves { padding: 29px 8px; color: var(--subtle); font-size: 12px; text-align: center; }
.rules-note { display: flex; gap: 10px; padding: 13px 15px; color: #9db0b9; border: 1px solid var(--line); border-radius: 15px; background: rgba(10,18,27,.7); font-size: 11px; line-height: 1.55; }
.rules-note span { color: var(--warm); font: 22px 'Times New Roman', serif; }
.rules-note p { margin: 0; }
.footer-note { margin-top: 27px; color: var(--subtle); font-size: 11px; text-align: center; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(3,7,11,.86); backdrop-filter: blur(8px); }
.modal-backdrop[hidden] { display: none; }
.promotion-dialog { width: min(390px, 100%); padding: 28px; border: 1px solid rgba(140,224,182,.32); border-radius: 22px; background: #142331; box-shadow: 0 25px 80px rgba(0,0,0,.6); text-align: center; }
.promotion-dialog h2 { margin: 5px 0 8px; font: 700 24px 'Space Grotesk', sans-serif; }
.promotion-dialog p:not(.eyebrow) { margin: 0 0 20px; color: #9db1bb; font-size: 13px; }
.promotion-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.promotion-choice { min-height: 68px; border: 1px solid #3e5b68; border-radius: 13px; color: #eff7f8; background: #1d3441; cursor: pointer; font: 38px 'Times New Roman', serif; transition: .18s; }
.promotion-choice:hover { border-color: var(--accent); background: #255248; transform: translateY(-2px); }

@media (max-width: 980px) {
  .app-shell { padding: 25px 20px; }
  .topbar { margin-bottom: 32px; }
  .game-layout { grid-template-columns: minmax(0, 720px); justify-content: center; gap: 28px; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .status-card, .moves-card { grid-column: span 2; }
  .rules-note { grid-column: span 2; }
}
@media (max-width: 560px) {
  .app-shell { padding: 17px 10px 20px; }
  .topbar { margin-bottom: 22px; }
  .brand-mark { width: 45px; height: 45px; border-radius: 14px; font-size: 26px; }
  .topbar h1 { font-size: 22px; }
  .topbar-meta { display: none; }
  .game-layout { gap: 19px; }
  .board-frame { padding: 7px; border-radius: 17px; }
  #tabuleiro { border-width: 2px; border-radius: 11px; }
  .casa { font-size: clamp(27px, 11vw, 50px); }
  .coord-file, .coord-rank { font-size: 8px; }
  .side-panel { display: flex; }
  .control-grid { gap: 7px; }
  .control-button { min-height: 42px; font-size: 11px; }
  .moves-card { min-height: 225px; }
  .move-list { max-height: 178px; }
  .rules-note { font-size: 10px; }
}

/* =========================================================
   INTERFACE LEVE — tabuleiro solto e visual menos tecnológico
========================================================= */
:root {
  --bg: #f3f1ed;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --panel-raised: #f8faf9;
  --line: #dfe4e2;
  --line-strong: #cbd4d0;
  --text: #25332e;
  --muted: #68756f;
  --subtle: #84908b;
  --accent: #3e795e;
  --accent-strong: #2d6048;
  --warm: #b87837;
  --danger: #b95852;
  --light-square: #f0d9b5;
  --dark-square: #b58863;
  --shadow: 0 18px 35px rgba(49, 54, 48, .13);
}

body {
  background: var(--bg);
  color: var(--text);
}

.app-shell { padding-top: 28px; }
.topbar { margin-bottom: 34px; }
.brand-mark {
  border-color: #c7d9ce;
  color: #f4faf6;
  background: var(--accent);
  box-shadow: none;
}
.eyebrow { color: var(--accent); }
.topbar h1 { color: var(--text); }
.version-badge {
  border-color: #b7d0bf;
  color: var(--accent-strong);
  background: #e3f0e7;
}
.topbar-meta {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}
.live-dot { background: var(--accent); box-shadow: none; }

/* O tabuleiro não fica mais dentro de um card: ele recebe apenas uma
   moldura discreta e sua própria sombra, como um tabuleiro sobre a mesa. */
.board-frame {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.board-frame:focus-within { outline: 3px solid #8db89c; outline-offset: 7px; }
#tabuleiro {
  border: 8px solid #fff;
  border-radius: 12px;
  box-shadow: 0 16px 30px rgba(49, 54, 48, .18), 0 2px 0 #d5c3a8;
}
.casa:hover { filter: brightness(1.04); }
.casa:focus-visible { outline-color: #d18b42; }
.casa.selecionada::before { box-shadow: inset 0 0 0 5px #4b8a68, inset 0 0 24px rgba(75, 138, 104, .25); }
.casa.ultimo-lance::before { background: rgba(229, 180, 87, .32); }

.player-card {
  min-height: 58px;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.player-avatar { border-radius: 50%; }
.player-avatar--dark { color: #fff; background: #526961; }
.player-avatar--light { background: #ead3ad; }
.player-side { color: var(--subtle); }
.player-side--light { color: var(--accent); }

.status-card {
  border-color: #c9dfd0;
  background: #e9f4ec;
  box-shadow: none;
}
.status-icon { color: var(--accent); background: #d7eadc; }
.status-copy strong { color: var(--text); }
.control-button, .setting-row, .moves-card {
  border-color: var(--line);
  color: var(--text);
  background: #fff;
  box-shadow: none;
}
.control-button:hover { color: var(--text); border-color: #aebeb5; background: #f8faf9; transform: translateY(-1px); }
.control-button span, .round-button { color: var(--accent); }
.control-button--primary { border-color: #a9cdb5; color: #24563d; background: #e3f0e7; }
.control-button--primary:hover { background: #d7eadc; }
.round-button { border-color: #bfd1c5; background: #f2f8f3; }
.section-heading { border-color: var(--line); }
.section-heading h2, .setting-row strong { color: var(--text); }
.move-row { color: #53615b; border-color: #edf0ee; }
.move-row .current { color: var(--accent-strong); }
.rules-note { color: #65716b; border-color: var(--line); background: #fff; }
.footer-note { color: var(--subtle); }

@media (max-width: 560px) {
  #tabuleiro { border-width: 5px; }
}
