/* Chesstive v1.53 Post-Cleanup: responsive left support rail, square board, right controls. */
body {
  display: block !important;
  min-height: 100dvh;
  margin: 0;
  padding: 0 !important;
  overflow-x: hidden;
}

body .app.chesstive-layout {
  --layout-page-pad: clamp(6px, .52vw, 10px);
  --layout-gap: clamp(10px, .65vw, 12px);
  --support-rail-width: clamp(150px, 15.55vw, 300px);
  --action-rail-width: clamp(300px, 33.15vw, 650px);
  --board-size-cap: calc(100dvh - 32px);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--action-rail-width);
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
  column-gap: var(--layout-gap);
  row-gap: clamp(8px, 1vh, 14px);
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 560px;
  margin: 0;
  padding: var(--layout-page-pad);
  overflow: visible;
}

/* The right header follows the red wordmark area in the supplied reference. */
.app.chesstive-layout .site-brand {
  position: static;
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 0;
  min-height: 0;
  margin: 0;
  z-index: auto;
}
.app.chesstive-layout .brand-lockup {
  --brand-title-size: clamp(48px, 4vw, 80px);
  --brand-mark-gap: clamp(6px, .45vw, 12px);
  --brand-mark-height: calc(var(--brand-title-size) * .84);
  --brand-mark-width: calc(var(--brand-mark-height) * .94);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  width: max-content;
  max-width: 100%;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
}
.app.chesstive-layout .brand-title-row {
  display: flex;
  align-items: center;
  gap: var(--brand-mark-gap);
  width: max-content;
  max-width: 100%;
}
.app.chesstive-layout .brand-mark {
  display: block;
  width: var(--brand-mark-width);
  height: var(--brand-mark-height);
  flex: 0 0 var(--brand-mark-width);
  filter: drop-shadow(0 2px 3px #0005);
}
.app.chesstive-layout .brand-title-row h1 {
  margin: 0;
  color: #f4f0df;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: var(--brand-title-size);
  font-weight: 700;
  line-height: .88;
  letter-spacing: .025em;
  text-transform: uppercase;
  white-space: nowrap;
}
.app.chesstive-layout .brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
  margin-left: calc(var(--brand-mark-width) + var(--brand-mark-gap));
}
.app.chesstive-layout .brand-copy .tagline {
  margin: 0;
  color: #d8bb72;
  font-size: clamp(10px, .78vw, 13px);
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1;
}
.app.chesstive-layout #connection-status {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0;
  color: #9bd2a0;
  font-size: clamp(9px, .68vw, 11px);
  font-weight: 650;
  letter-spacing: .025em;
  line-height: 1;
}
.app.chesstive-layout #connection-status.offline { color: #efaa9b; }

/* Left rail: player identity and stats above the independently sized Power-Up shelf. */
.app.chesstive-layout .board-column {
  position: relative;
  grid-column: 1;
  grid-row: 1 / 3;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  z-index: auto;
}
.app.chesstive-layout .board-game-layout {
  display: grid;
  grid-template-columns: var(--support-rail-width) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(12px, 1.25vw, 24px);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.app.chesstive-layout .board-support-column {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(8px, 1.2vh, 12px);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.app.chesstive-layout .player-summary {
  display: grid;
  grid-template-rows: repeat(2, clamp(58px, 10vh, 100px));
  gap: clamp(8px, 1.2vh, 12px);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  color: #f4f0df;
}
.app.chesstive-layout .player-summary .summary-box {
  position: static;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
.app.chesstive-layout .player-summary .username-box {
  justify-content: center;
  overflow: hidden;
  color: #f4f0df;
  font-size: clamp(26px, 2.1vw, 38px);
  font-weight: 850;
  text-overflow: ellipsis;
}
.app.chesstive-layout .summary-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(6px, .7vw, 12px);
  min-width: 0;
}
.app.chesstive-layout .player-summary .score-box {
  justify-content: flex-start;
  width: 6ch;
  color: #f4f0df;
  font-size: clamp(26px, 2vw, 36px);
  font-weight: 900;
  text-align: left;
  transition: color .15s ease, transform .15s ease;
}
.app.chesstive-layout .player-summary .score-box.score-counting {
  color: #e7b84f;
  transform: scale(1.04);
  transform-origin: left center;
}
.app.chesstive-layout .player-summary .aura-box {
  display: flex;
  justify-content: flex-end;
  gap: .18em;
  color: #e7b84f;
  font-size: clamp(17px, 1.28vw, 24px);
  font-weight: 900;
}
.app.chesstive-layout .player-summary .aura-label { color: #e7b84f; }

.app.chesstive-layout .powerup-card-rail {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  justify-items: center;
  gap: var(--powerup-gap, 8px);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  scrollbar-width: none;
}
.app.chesstive-layout .powerup-card-rail::-webkit-scrollbar { display: none; }
.app.chesstive-layout .powerup-card-rail[hidden] { display: none !important; }
.app.chesstive-layout .active-powerup-cards { display: contents; width: auto; gap: 0; }

/* The board stage has its own fixed square; card count never enters its sizing. */
.app.chesstive-layout .board-stage {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.app.chesstive-layout .board-wrap {
  position: relative;
  box-sizing: border-box;
  width: min(100%, var(--board-size-cap));
  height: auto;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0;
}
.app.chesstive-layout .board {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border-width: var(--chess-outline);
  aspect-ratio: 1;
}
.app.chesstive-layout #sound-toggle {
  position: absolute;
  z-index: 30;
  top: clamp(8px, 1vw, 16px);
  right: clamp(8px, 1vw, 16px);
  width: var(--chess-sound-size);
  height: var(--chess-sound-size);
  margin: 0;
  padding: 0;
  transform: none;
}
.app.chesstive-layout #sound-toggle svg { width: 58%; height: 58%; }

/* Right rail: primary actions first, secondary tools last. */
.app.chesstive-layout .action-column {
  position: static;
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  align-content: center;
  justify-content: center;
  gap: clamp(10px, 1.35vh, 16px);
  box-sizing: border-box;
  width: min(100%, 480px);
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  pointer-events: auto;
}
.app.chesstive-layout .action-column > button {
  position: static;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(100%, 320px);
  min-width: 0;
  min-height: clamp(50px, 5.2vh, 64px);
  max-width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #53685b;
  border-radius: 7px;
  background: #26352f;
  color: #f4f0df;
  font: 750 clamp(13px, 1.05vw, 16px)/1.2 system-ui, sans-serif;
  text-align: center;
  white-space: normal;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, filter .15s ease;
}
.app.chesstive-layout .action-column > button:hover { background: #30443a; border-color: #b89450; }
.app.chesstive-layout .action-column > button:focus-visible { outline: 2px solid #e7b84f; outline-offset: 2px; }
.app.chesstive-layout .action-column > button[hidden] { display: none !important; }
.app.chesstive-layout .action-column .nav-lock-icon,
.app.chesstive-layout .action-column .hardcore-mode-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: #d8bb72;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app.chesstive-layout .action-column #enter-chesstive-button {
  border-color: #b89450;
  background: #e7b84f;
  color: #17231f;
}
.app.chesstive-layout .action-column #enter-chesstive-button:hover { background: #f0c55c; }
.app.chesstive-layout .action-column #development-open { color: #d5dbd1; font-size: clamp(12px, .95vw, 14px); }
.app.chesstive-layout .action-column .hardcore-mode-button[aria-disabled="true"] { color: #d5dbd1; cursor: pointer; opacity: 1; }
.app.chesstive-layout .side[hidden] { display: none !important; }

/* Account, PVP, Ethics, and Development Tools retain their existing pop-outs. */
.ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 2450;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(12px, 3vw, 24px);
  background: #080e0cdd;
  backdrop-filter: blur(5px);
}
.ui-overlay[hidden] { display: none !important; }
.ui-dialog {
  box-sizing: border-box;
  width: min(100%, 620px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: clamp(14px, 2.5vw, 24px);
  border: 1px solid #53685b;
  border-radius: 10px;
  background: #26352f;
  color: #f4f0df;
  box-shadow: 0 16px 46px #0008;
}
.ui-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 0 0 10px;
  border-bottom: 1px solid #40564a;
}
.ui-dialog-header h2 {
  margin: 0;
  color: #f4f0df;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(23px, 4vw, 34px);
  font-weight: 500;
  letter-spacing: .045em;
}
.ui-dialog-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid #53685b;
  border-radius: 6px;
  background: #1c2a25;
  color: #e7b84f;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.account-popout-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 430px;
  margin: 0 auto;
}
.account-popout-content .signin-card {
  width: 100%;
  max-width: 430px;
  margin: 0;
  padding: 16px;
}
.account-popout-content .signin-card h2 { font-size: clamp(24px, 4vw, 32px); }
.account-popout-content .signin-card > p:not(.signin-brand) { font-size: 12px; }
.account-popout-content .signin-card form { gap: 7px; margin-top: 11px; }
.account-popout-content .signin-card label { font-size: 11px; }
.account-popout-content .signin-card button { font-size: 12px; }
.account-popout-content .account-card { width: 100%; margin: 0; }
.account-popout-content .account-content { max-height: none; overflow: visible; }
#arena-info-overlay .ui-dialog { width: min(100%, 500px); }
#arena-info-overlay #pvp-arena-card {
  position: static;
  inset: auto;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 8px 8px 14px;
  box-shadow: none;
}
#arena-info-overlay #pvp-arena-card h2 { margin: 12px 0 8px; }
#arena-info-overlay .pvp-arena-emblem { width: min(100%, 230px); margin: 16px auto 5px; }
#ethics-overlay .ui-dialog { width: min(100%, 700px); }
#ethics-overlay .vision-ethics {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
#ethics-overlay .vision-ethics h2 { margin-top: 8px; }
#development-overlay .ui-dialog { width: min(100%, 650px); }
#development-overlay .dev-tools {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#development-overlay .dev-key-form { margin-top: 12px; }
#pvp-overlay { z-index: 2600; }

@media (max-width: 1150px) {
  .app.chesstive-layout .brand-lockup { --brand-title-size: clamp(38px, 4.2vw, 48px); }
}

@media (max-width: 900px) {
  body .app.chesstive-layout {
    --page-board-gap: clamp(12px, 2vw, 18px);
    --support-rail-width: clamp(145px, 24vw, 220px);
    --action-rail-width: auto;
    --board-size-cap: min(calc(100dvh - 90px), calc(100vw - var(--support-rail-width) - var(--page-board-gap) - 2 * var(--layout-page-pad)));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: clamp(12px, 2vh, 18px);
    height: auto;
    min-height: 100dvh;
  }
  .app.chesstive-layout .site-brand {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-end;
  }
  .app.chesstive-layout .board-column {
    grid-column: 1;
    grid-row: 2;
    height: auto;
    min-height: 0;
  }
  .app.chesstive-layout .board-game-layout {
    height: auto;
    min-height: 0;
  }
  .app.chesstive-layout .board-support-column { min-height: var(--board-size-cap); }
  .app.chesstive-layout .powerup-card-rail { min-height: 0; }
  .app.chesstive-layout .board-stage { height: auto; min-height: var(--board-size-cap); }
  .app.chesstive-layout .action-column {
    grid-column: 1;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
    gap: 10px;
    width: 100%;
    height: auto;
    max-width: 700px;
    justify-self: center;
    overflow: visible;
  }
  .app.chesstive-layout .action-column > button { width: 100%; min-height: 48px; padding: 8px; font-size: 12px; }
}

@media (max-width: 580px) {
  body .app.chesstive-layout {
    --support-rail-width: 100%;
    --board-size-cap: min(calc(100vw - 2 * var(--layout-page-pad)), calc(100dvh - 190px));
    grid-template-rows: auto auto auto;
    padding-bottom: 18px;
  }
  .app.chesstive-layout .site-brand { justify-content: center; }
  .app.chesstive-layout .brand-lockup { --brand-title-size: clamp(32px, 7.8vw, 44px); --brand-mark-gap: 8px; }
  .app.chesstive-layout .board-game-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .app.chesstive-layout .board-support-column {
    grid-column: 1;
    grid-row: 1;
    grid-template-rows: auto minmax(0, auto);
    height: auto;
    min-height: 0;
  }
  .app.chesstive-layout .player-summary {
    grid-template-rows: auto auto;
    gap: 8px;
  }
  .app.chesstive-layout .player-summary .username-box { min-height: 38px; font-size: clamp(24px, 7vw, 32px); }
  .app.chesstive-layout .summary-stat-row { min-height: 36px; }
  .app.chesstive-layout .player-summary .score-box { font-size: clamp(24px, 7vw, 32px); }
  .app.chesstive-layout .player-summary .aura-box { font-size: clamp(16px, 4.8vw, 20px); }
  .app.chesstive-layout .powerup-card-rail {
    grid-column: 1;
    grid-row: 2;
    height: min(26dvh, 210px);
    min-height: 0;
  }
  .app.chesstive-layout .board-stage { grid-column: 1; grid-row: 2; min-height: 0; }
  .app.chesstive-layout .board-wrap { width: min(100%, var(--board-size-cap)); }
  .app.chesstive-layout .action-column { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .app.chesstive-layout .action-column > button { min-height: 46px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .app.chesstive-layout .action-column > button { transition: none; }
}
