.room-header { width: min(100%, 1500px); min-height: 58px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgb(255 255 255 / 5%); }
.room-brand { width: 138px; display: block; }
.room-brand img { width: 100%; display: block; }
.room-meta { display: flex; align-items: center; gap: 9px; }

.room-page { width: min(100% - 40px, 1080px); min-height: calc(100dvh - 58px); margin: 0 auto; padding: 24px 0; display: grid; grid-template-columns: minmax(0, 620px) minmax(280px, 320px); justify-content: center; align-items: center; gap: 22px; }
.room-page::before { position: fixed; z-index: -1; inset: 0; content: ""; pointer-events: none; background: linear-gradient(rgb(255 255 255 / .8%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .8%) 1px, transparent 1px), radial-gradient(circle at 27% 35%, rgb(249 115 22 / 6%), transparent 28%); background-size: 50px 50px, 50px 50px, auto; }
.match-area { min-width: 0; padding: 12px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 7px; background: rgb(18 16 14 / 92%); box-shadow: 0 24px 70px rgb(0 0 0 / 25%); }
.match-heading { min-height: 38px; padding: 0 2px 8px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.match-heading > div { display: grid; gap: 3px; }
.match-heading span, .panel-label { color: var(--laranja); font-size: 8px; font-weight: 850; letter-spacing: .16em; }
.match-heading strong { color: var(--texto); font-size: 13px; line-height: 1.25; }
.match-heading small { color: var(--texto-suave); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.match-heading .match-state { padding: 7px 9px; color: var(--laranja-suave); border-radius: 7px; background: rgb(249 115 22 / 10%); font-size: 8px; white-space: nowrap; }

.player { min-height: 48px; padding: 5px 0; display: flex; align-items: center; gap: 10px; }
.player-photo { width: 34px; height: 34px; display: grid; place-items: center; overflow: hidden; color: #fff; border-radius: 7px; background: var(--laranja); font-size: 11px; font-weight: 900; }
.player-photo img { width: 100%; height: 100%; object-fit: cover; }
.player-photo-rival { background: #38322e; }
.player-copy { display: grid; gap: 2px; }
.player-copy strong { font-size: 12px; line-height: 1.1; }
.player-copy small { color: var(--texto-suave); font-size: 9px; }
.player-copy .opponent-presence { color: #df8a62; font-weight: 750; }
.player-clock { min-width: 52px; margin-left: auto; padding: 8px 10px; color: var(--texto); border-radius: 7px; background: #28231f; font-size: 13px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.player-clock.active { color: var(--laranja-suave); background: rgb(249 115 22 / 10%); }

.board-shell { position: relative; padding-bottom: 15px; }
.room-board { width: min(100%, calc(100dvh - 330px)); aspect-ratio: 1; margin: 0 auto; display: grid; grid-template-columns: repeat(8, 1fr); overflow: hidden; border: 1px solid #4b372b; border-radius: 7px; background: #d8c6b0; box-shadow: 0 12px 34px rgb(0 0 0 / 22%); transform: translateZ(0); backface-visibility: hidden; }
.board-cell { position: relative; display: grid; place-items: center; border: 0; padding: 0; backface-visibility: hidden; }
.board-cell.light { background: #d9c7b2; }
.board-cell.dark { background: #875538; cursor: pointer; }
.board-cell.selected { background: #ce611f; }
.board-cell.valid-move::after { position: absolute; width: 18%; aspect-ratio: 1; content: ""; border-radius: 50%; background: rgb(255 255 255 / 72%); box-shadow: 0 0 0 5px rgb(255 255 255 / 10%); }
.checker { position: relative; z-index: 1; width: 68%; aspect-ratio: 1; display: block; border-radius: 50%; backface-visibility: hidden; transition: transform 160ms ease, box-shadow 160ms ease; }
.dark:hover .checker { transform: translateY(-3px); }
.checker.white, .checker.black { cursor: grab; touch-action: none; }
.checker.white:active, .checker.black:active { cursor: grabbing; }
.checker.is-drag-source { opacity: .35; transform: scale(.92); }
.checker-drag-ghost { position: fixed; z-index: 999; left: 0; top: 0; pointer-events: none; opacity: .96; transform-origin: center; filter: drop-shadow(0 12px 18px rgb(0 0 0 / 30%)); will-change: transform; }
.checker.black { border: 4px solid #24211f; background: #38332f; box-shadow: inset 0 0 0 4px rgb(255 255 255 / 7%), 0 5px 7px rgb(0 0 0 / 28%); }
.checker.white { border: 4px solid #e8e1d8; background: #faf8f4; box-shadow: inset 0 0 0 4px rgb(0 0 0 / 4%), 0 5px 7px rgb(0 0 0 / 22%); }
.checker.king::after { position: absolute; inset: 50% auto auto 50%; content: "♛"; transform: translate(-50%, -52%); color: #f97316; font-size: clamp(14px, 2.2vw, 25px); line-height: 1; text-shadow: 0 1px 1px rgb(0 0 0 / 45%); }
.board-files { position: absolute; inset: auto 0 -1px; padding: 0 3%; display: grid; grid-template-columns: repeat(8, 1fr); color: #6e655e; font-size: 8px; font-weight: 800; text-align: center; }

.match-panel { position: sticky; top: 72px; display: grid; gap: 10px; }
.panel-section { padding: 18px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 7px; background: rgb(20 18 16 / 72%); }
.invitation-panel { border-color: rgb(249 115 22 / 28%); border-left: 3px solid var(--laranja); background: linear-gradient(135deg, rgb(249 115 22 / 8%), rgb(20 18 16 / 86%) 45%); }
.invitation-panel[hidden] { display: none; }
.panel-section h2 { margin: 9px 0 7px; font-size: 17px; line-height: 1.2; }
.panel-section p { margin: 0; color: var(--texto-suave); font-size: 10px; line-height: 1.55; }
.room-invite-code { margin-top: 16px; padding: 10px 9px 10px 13px; display: flex; align-items: center; justify-content: space-between; border: 1px dashed rgb(249 115 22 / 28%); border-radius: 7px; background: rgb(0 0 0 / 18%); }
.room-invite-code strong { font-size: 16px; letter-spacing: .17em; }
.room-invite-code button { width: 34px; height: 32px; display: grid; place-items: center; color: var(--laranja); border: 1px solid rgb(249 115 22 / 26%); border-radius: 7px; background: rgb(249 115 22 / 7%); cursor: pointer; }
.room-invite-code svg { width: 14px; }
.action-list { margin-top: 14px; display: grid; gap: 8px; }
.action-list button { min-height: 48px; padding: 8px 10px; display: flex; align-items: center; gap: 11px; color: var(--texto); border: 1px solid rgb(255 255 255 / 6%); border-radius: 7px; background: transparent; text-align: left; cursor: pointer; }
.action-list button:hover { border-color: rgb(249 115 22 / 24%); background: rgb(249 115 22 / 5%); }
.action-list svg { width: 16px; color: var(--texto-suave); }
.action-list span { display: grid; gap: 2px; font-size: 10px; font-weight: 750; }
.action-list small { color: #746c66; font-size: 8px; font-weight: 500; }
.action-list button:disabled { cursor: default; opacity: .55; }
.draw-offer-panel { border-left-color: var(--laranja); }
.draw-offer-panel h2 { margin: 10px 0 16px; color: var(--texto); font-size: 15px; }
.draw-offer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.draw-offer-actions button { min-height: 40px; color: var(--texto); border: 1px solid rgb(255 255 255 / 10%); border-radius: 7px; background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }
.draw-offer-actions .draw-accept-button { color: #fff; border-color: var(--laranja); background: var(--laranja); }
.draw-offer-actions button:disabled { cursor: default; opacity: .55; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; }
.chat-heading svg { width: 15px; color: var(--texto-suave); }
.chat-messages {
  height: 130px;
  padding: 14px 10px 14px 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / 14%) transparent;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { border-radius: 7px; background: rgb(255 255 255 / 12%); }
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgb(255 255 255 / 18%); }
.system-message { color: #746c66 !important; font-size: 9px !important; text-align: center; }
.chat-message { width: fit-content; max-width: 86%; margin: 7px auto 0 0; padding: 8px 10px; display: grid; gap: 3px; color: var(--texto); border-radius: 7px 7px 7px 2px; background: rgb(255 255 255 / 5%); }
.chat-message.own-message { margin-left: auto; margin-right: 0; border-radius: 7px 7px 2px 7px; background: rgb(249 115 22 / 10%); }
.chat-message-author { color: var(--laranja); font-size: 8px; font-weight: 800; }
.chat-message-text { overflow-wrap: anywhere; font-size: 10px; line-height: 1.45; }
.chat-message-time { color: var(--texto-suave); font-size: 7px; text-align: right; }
.chat-form { display: grid; grid-template-columns: 1fr 40px; }
.chat-form input { min-width: 0; min-height: 40px; padding: 0 11px; color: var(--texto); border: 1px solid rgb(255 255 255 / 8%); border-right: 0; border-radius: 7px 0 0 7px; outline: 0; background: rgb(0 0 0 / 18%); font: inherit; font-size: 10px; }
.chat-form input:focus { border-color: var(--laranja); }
.chat-form button { color: #fff; border: 1px solid var(--laranja); border-radius: 0 7px 7px 0; background: var(--laranja); box-shadow: inset 0 -2px 0 rgb(0 0 0 / 18%); cursor: pointer; }
.chat-form button:disabled { cursor: default; opacity: .55; }
.chat-form svg { width: 14px; }

.result-overlay { position: fixed; z-index: 1000; inset: 0; padding: 20px; display: grid; place-items: center; background: rgb(8 7 6 / 78%); backdrop-filter: blur(7px); }
.result-overlay[hidden] { display: none; }
.result-card { width: min(100%, 390px); padding: 34px; display: grid; justify-items: center; border: 1px solid rgb(249 115 22 / 32%); border-left: 3px solid var(--laranja); border-radius: 7px; background: #191613; box-shadow: 0 28px 90px rgb(0 0 0 / 55%); text-align: center; }
.result-icon { width: 52px; height: 52px; margin-bottom: 20px; display: grid; place-items: center; color: var(--laranja); border: 1px solid rgb(249 115 22 / 34%); border-radius: 7px; background: rgb(249 115 22 / 9%); }
.result-icon svg { width: 24px; height: 24px; }
.result-card h2 { margin: 10px 0 8px; color: var(--texto); font-size: 32px; line-height: 1.05; }
.result-card p { margin: 0; color: var(--texto-suave); font-size: 13px; line-height: 1.55; }
.result-actions { width: 100%; margin-top: 22px; display: grid; gap: 9px; }
.result-home-button, .result-rematch-button { width: 100%; min-height: 46px; display: grid; place-items: center; border-radius: 7px; font: inherit; font-size: 12px; font-weight: 850; text-decoration: none; cursor: pointer; }
.result-home-button { color: var(--texto); border: 1px solid rgb(255 255 255 / 11%); background: transparent; }
.result-rematch-button { color: #fff; border: 1px solid var(--laranja); background: var(--laranja); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%); }
.result-rematch-button:disabled { cursor: default; opacity: .6; }
.result-home-button:hover { filter: brightness(1.06); }
.rematch-response { width: 100%; margin-top: 20px; padding: 14px; border: 1px solid rgb(249 115 22 / 24%); border-radius: 7px; background: rgb(249 115 22 / 7%); }
.rematch-response[hidden] { display: none; }
.rematch-response strong { color: var(--texto); font-size: 12px; }
.rematch-response-actions { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rematch-response-actions button { min-height: 40px; color: var(--texto); border: 1px solid rgb(255 255 255 / 11%); border-radius: 7px; background: transparent; font: inherit; font-size: 10px; font-weight: 800; cursor: pointer; }
.rematch-response-actions button:first-child { color: #fff; border-color: var(--laranja); background: var(--laranja); }
.rematch-response-actions button:disabled { cursor: default; opacity: .55; }
.result-card .rematch-feedback { min-height: 18px; margin-top: 12px; color: var(--laranja); font-size: 10px; }
.confirmation-card { justify-items: stretch; }
.confirmation-card .result-icon, .confirmation-card .panel-label, .confirmation-card h2, .confirmation-card > p { justify-self: center; }
.confirmation-actions { width: 100%; margin-top: 25px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.confirmation-actions button { min-height: 46px; padding: 8px 12px; color: var(--texto); border: 1px solid rgb(255 255 255 / 12%); border-radius: 7px; background: transparent; cursor: pointer; font-size: 11px; font-weight: 850; }
.confirmation-actions .confirmation-danger-button { color: #fff; border-color: var(--laranja); background: var(--laranja); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%); }
.confirmation-actions button:hover { filter: brightness(1.06); }
.confirmation-actions button:disabled { cursor: wait; opacity: .58; }
.confirmation-feedback { margin-top: 14px !important; color: #ff7777 !important; }

@media (max-width: 920px) {
  .room-page { width: min(100% - 32px, 760px); min-height: auto; padding: 22px 0 44px; grid-template-columns: 1fr; align-items: start; gap: 14px; }
  .match-area, .match-panel, .panel-section { width: 100%; min-width: 0; }
  .match-panel { position: static; grid-template-columns: 1fr 1fr; gap: 10px; }
  .chat-panel { grid-column: 1 / -1; }
  .board-shell { width: 100%; min-width: 0; }
  .room-board { width: 100%; max-width: 100%; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); }
  .board-cell { width: 100%; min-width: 0; min-height: 0; }
  .panel-section { padding: 16px; }
  .chat-messages { height: 112px; }
}

@media (max-width: 600px) {
  .room-header { min-height: 58px; padding: 0 12px; gap: 10px; }
  .room-brand { width: 116px; }
  .room-meta { gap: 7px; }
  .shared-account .user-account-nickname { max-width: 72px; }
  .room-page { width: calc(100% - 18px); padding-top: 12px; gap: 10px; }
  .match-area { padding: 8px; }
  .match-heading { min-height: 34px; padding-inline: 2px; gap: 10px; }
  .match-heading span { font-size: 7px; }
  .match-heading strong { font-size: 11px; }
  .match-heading small { font-size: 7px; }
  .match-heading .match-state { padding: 6px 7px; font-size: 7px; }
  .player { min-height: 43px; padding: 4px 0; gap: 8px; }
  .player-photo { width: 31px; height: 31px; }
  .player-copy strong { font-size: 11px; }
  .player-copy small { font-size: 8px; }
  .player-clock { min-width: 46px; padding: 7px 8px; font-size: 11px; }
  .board-shell { padding-bottom: 12px; }
  .checker { width: 72%; }
  .checker.black, .checker.white { border-width: 3px; }
  .match-panel { grid-template-columns: 1fr; }
  .panel-section { padding: 14px; }
  .panel-section h2 { font-size: 15px; }
  .panel-section p { font-size: 9px; }
  .room-invite-code { margin-top: 12px; }
  .room-invite-code strong { font-size: 14px; }
  .match-actions { display: block; }
  .action-list { grid-template-columns: 1fr 1fr; }
  .action-list button { min-height: 44px; }
  .chat-panel { grid-column: auto; }
  .chat-messages { height: 86px; padding: 10px 8px 10px 0; }
  .chat-form { grid-template-columns: 1fr 38px; }
  .chat-form input { min-height: 38px; font-size: 9px; }
  .result-card { padding: 28px 22px; }
  .result-card h2 { font-size: 27px; }
  .confirmation-actions { grid-template-columns: 1fr; }
}

/* Mantém a área interna do tabuleiro divisível por 8 nos celulares. */
@media (max-width: 373px) {
  .room-board { width: 282px; }
}

@media (min-width: 374px) and (max-width: 389px) {
  .room-board { width: 338px; }
}

@media (min-width: 390px) and (max-width: 429px) {
  .room-board { width: 354px; }
}

@media (min-width: 430px) and (max-width: 600px) {
  .room-board { width: 394px; }
}

@media (max-width: 420px) {
  .shared-account .user-account-nickname { display: none; }
  .room-brand { width: 108px; }
  .match-heading { align-items: flex-start; }
  .match-heading .match-state { display: none; }
  .player-clock { min-width: 42px; font-size: 10px; }
  .board-files { font-size: 7px; }
}
