/* ChessApp v2.0 responsive play layout */

:root {
  --play-gap: 16px;
  --play-board-size: min(68vh, 650px, calc(100vw - 720px));
  --play-header-height: 68px;
}

html,
body {
  min-width: 0;
  overflow-x: hidden;
}

body {
  background-attachment: fixed;
}

.site-header {
  min-height: var(--play-header-height);
  padding: 10px clamp(14px, 2.5vw, 32px);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 25px;
}

.app-shell {
  width: min(1510px, calc(100% - 24px));
  max-width: 1510px;
  padding: 16px 0 34px;
}

/* Keep SEO copy in the document, but make the live game the visual priority. */
.hero-copy {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#topAdSlot {
  display: none !important;
}

.game-layout {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns:
    minmax(460px, var(--play-board-size))
    minmax(310px, 360px)
    minmax(250px, 300px);
  justify-content: center;
  align-items: start;
  gap: var(--play-gap);
}

.board-panel,
.control-panel,
.ad-rail {
  min-width: 0;
}

.board-panel {
  width: 100%;
  padding: 12px;
  border-radius: 20px;
}

.player-strip {
  min-height: 50px;
  padding: 2px 4px 9px;
  gap: 9px;
}

.player-strip:last-child {
  padding: 9px 4px 2px;
}

.avatar {
  width: 38px;
  height: 38px;
  font-size: 21px;
}

.board-wrap {
  width: 100%;
  max-width: var(--play-board-size);
  padding: 7px;
  border-radius: 16px;
}

.chessboard {
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
}

.control-panel {
  width: 100%;
  position: sticky;
  top: calc(var(--play-header-height) + 12px);
  max-height: calc(100vh - var(--play-header-height) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
  border-radius: 20px;
  scrollbar-width: thin;
}

.status-card {
  padding: 16px;
}

.status-card strong {
  font-size: clamp(20px, 2vw, 24px);
}

.move-list {
  max-height: clamp(170px, 30vh, 320px);
}

.feature-grid {
  margin-top: 18px;
}

/* Original right-side advertisement placeholder. Real AdSense code can replace its inner content later. */
.ad-rail {
  width: 100%;
  position: sticky;
  top: calc(var(--play-header-height) + 12px);
}

.ad-creative {
  min-height: min(72vh, 660px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  position: relative;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--primary) 18%);
  border-radius: 20px;
  color: #f8fbff;
  background:
    radial-gradient(circle at 20% 12%, rgba(149, 225, 107, .42), transparent 27%),
    radial-gradient(circle at 92% 72%, rgba(88, 161, 255, .32), transparent 32%),
    linear-gradient(155deg, #17232e 0%, #243646 48%, #121a22 100%);
  box-shadow: var(--shadow);
}

.ad-creative::before,
.ad-creative::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ad-creative::before {
  width: 170px;
  height: 170px;
  right: -55px;
  top: 28%;
  border: 28px solid rgba(255, 255, 255, .045);
}

.ad-creative::after {
  width: 125px;
  height: 125px;
  left: -48px;
  bottom: 15%;
  background: rgba(126, 205, 94, .08);
}

.ad-slot-label {
  align-self: flex-start;
  position: relative;
  z-index: 1;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  color: rgba(255, 255, 255, .76);
  background: rgba(7, 13, 19, .28);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ad-chess-art {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 180px;
  font-size: clamp(92px, 9vw, 132px);
  line-height: 1;
  color: #ffffff;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, .18),
    0 18px 34px rgba(0, 0, 0, .4);
}

.ad-copy {
  position: relative;
  z-index: 1;
}

.ad-copy h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 2.7vw, 38px);
  line-height: 1.02;
  letter-spacing: -.04em;
}

.ad-copy p {
  margin: 0;
  color: rgba(238, 246, 251, .76);
  font-size: 14px;
  line-height: 1.55;
}

.ad-cta {
  position: relative;
  z-index: 1;
  min-height: 50px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(180deg, #8fdb69, #66ae47);
  color: #102011;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(42, 83, 32, .65), 0 15px 28px rgba(0, 0, 0, .25);
}

.ad-dimensions {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, .56);
  font-size: 10px;
  text-align: center;
  letter-spacing: .08em;
}

/* Medium desktop and tablet: board + controls, with a horizontal ad beneath. */
@media (max-width: 1179px) {
  :root {
    --play-board-size: min(70vh, 680px, calc(100vw - 390px));
  }

  .app-shell {
    width: min(1080px, calc(100% - 20px));
  }

  .game-layout {
    grid-template-columns: minmax(430px, var(--play-board-size)) minmax(300px, 350px);
  }

  .ad-rail {
    grid-column: 1 / -1;
    position: static;
  }

  .ad-creative {
    min-height: 150px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
  }

  .ad-chess-art {
    min-height: 0;
    font-size: 76px;
  }

  .ad-copy h2 {
    font-size: 27px;
  }

  .ad-cta {
    min-width: 170px;
    padding: 0 18px;
  }

  .ad-slot-label,
  .ad-dimensions {
    display: none;
  }
}

/* Mobile and narrow tablet: one clean vertical flow. */
@media (max-width: 899px) {
  :root {
    --play-board-size: min(100%, calc(100vw - 20px));
  }

  .site-header {
    min-height: 62px;
    padding: 8px 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 23px;
  }

  .app-shell {
    width: 100%;
    padding: 10px 8px 28px;
  }

  .game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .board-panel,
  .control-panel,
  .ad-rail {
    width: 100%;
    max-width: 720px;
    margin-inline: auto;
  }

  .board-panel {
    padding: 9px;
    border-radius: 16px;
  }

  .board-wrap {
    width: 100%;
    max-width: none;
    padding: 5px;
    border-radius: 12px;
  }

  .chessboard {
    border-radius: 8px;
  }

  .control-panel {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 14px;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .status-card,
  .moves-card,
  .small-actions {
    grid-column: 1 / -1;
  }

  .ad-rail {
    grid-column: auto;
  }

  .ad-creative {
    min-height: 130px;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
    border-radius: 16px;
  }

  .ad-chess-art {
    font-size: 64px;
  }

  .ad-copy h2 {
    font-size: 22px;
    margin-bottom: 6px;
  }

  .ad-copy p {
    font-size: 12px;
  }

  .ad-cta,
  .ad-slot-label,
  .ad-dimensions {
    display: none;
  }

  .feature-grid {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand small,
  .theme-label {
    display: none;
  }

  .header-actions {
    gap: 7px;
  }

  .icon-button,
  .theme-toggle {
    min-height: 38px;
  }

  .icon-button {
    width: 38px;
  }

  .board-panel {
    padding: 7px;
  }

  .player-strip {
    min-height: 46px;
    padding-inline: 1px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }

  .control-panel {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .status-card,
  .moves-card,
  .small-actions {
    grid-column: auto;
  }

  .setup-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .primary-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .primary-actions .primary {
    grid-column: 1 / -1;
  }

  .button {
    min-height: 44px;
    padding-inline: 10px;
  }

  .move-list {
    max-height: 190px;
  }

  .ad-creative {
    min-height: 112px;
    grid-template-columns: 54px minmax(0, 1fr);
    padding: 13px;
  }

  .ad-chess-art {
    font-size: 50px;
  }

  .ad-copy h2 {
    font-size: 18px;
  }

  .ad-copy p {
    font-size: 11px;
    line-height: 1.4;
  }

  footer {
    padding: 16px 12px;
  }
}

@media (max-height: 720px) and (min-width: 1180px) {
  :root {
    --play-board-size: min(62vh, 560px, calc(100vw - 720px));
  }

  .player-strip {
    min-height: 44px;
  }

  .control-panel {
    gap: 12px;
    padding: 13px;
  }

  .status-card {
    padding: 13px;
  }

  .move-list {
    max-height: 180px;
  }
}
