/* Browser presentation. Shared chess boards, controls and Android styles are imported first. */
:root {
  color-scheme: dark;
  --web-base: #201913;
  --web-surface: #30251c;
  --web-raised: #3b2e23;
  --web-border: #65503c;
  --web-text: #fff6e9;
  --web-muted: #d6c1a8;
  --web-accent: #edc789;
  --web-radius: 16px;
}
:root[data-theme="green"] {
  --web-base: #181e18;
  --web-surface: #242e23;
  --web-raised: #303d2e;
  --web-border: #52664d;
  --web-text: #f2f7e8;
  --web-muted: #c2cfb7;
  --web-accent: #c9e39a;
}
body { font-family: "Segoe UI", system-ui, sans-serif; background: var(--web-base); }
:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--web-accent); outline-offset: 3px;
}
.sheet:modal {
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  box-shadow: 0 24px 75px #0007;
  max-width: calc(100vw - 20px);
}
.sheet::backdrop { background: #100d0bbd; }
#playHub.homeActive { overflow: auto; }
@media (min-width: 850px) {
  #playHub.homeActive { padding-inline: max(24px, calc((100vw - 1040px)/2)); }
  #playHub.homeActive #hubHome { max-width: 1040px; }
}
#playHub.homeActive #hubHome {
  width: min(100%, 1120px); height: auto; min-height: 0;
  margin-inline: auto; gap: clamp(14px, 3vw, 30px);
}
#playHub.homeActive #hubHome .homeOptions {
  flex: none; grid-template-rows: none; grid-auto-rows: auto;
  gap: clamp(8px, 1.4vw, 16px);
}
#playHub.homeActive #hubHome .homeOptions button {
  min-height: clamp(76px, 12vw, 135px);
  padding: clamp(10px, 1.8vw, 22px);
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface); box-shadow: 0 8px 22px #0002;
}
#playHub.homeActive #hubHome .homeOptions button:hover { background: var(--web-raised); border-color: var(--web-accent); }
#playHub.homeActive #hubHome .homeOptions strong { font-weight: 650; }
#playHub.homeActive #hubHome .hubHeading > .eyebrow { display: none; }
#gameOverview .overviewPlayer, #gameOverview .web-move-breakdown {
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface);
}
#gameOverview .web-move-breakdown { padding: 8px 14px; min-width: 0; }
#gameOverview .overviewActions { border-top: 1px solid var(--web-border); }
#gameOverview #overviewStart:not(:disabled) { background: var(--web-accent); color: var(--web-base); }
#gameOverview .overviewProgress:has(progress[value="100"]) progress { display: none; }
:is(#playSetup,#savedGamesPage,#lessonList,#onlineLobby) {
  scrollbar-color: var(--web-border) transparent;
}
:is(.botCards button,.lessonCard,.savedGame) { border-radius: 12px; }
#playScreen #playMoves {
  background: var(--web-base); border: 1px solid var(--web-border);
  border-radius: 10px; padding: 8px 12px; line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
#webListen { min-height: 32px; white-space: nowrap; }
.web-voice-settings { display: grid; gap: 8px; margin-block: 10px; }
.web-voice-settings label { display: grid; gap: 4px; }
.web-voice-settings select { max-width: 100%; }
@media (min-width: 850px) and (min-height: 580px) {
  #playHub.homeActive #hubHome .hubHeading {
    display: grid; grid-template-columns: minmax(0,1fr) auto;
    padding: clamp(18px, 5vh, 54px) 0 0; row-gap: 10px; align-items: center;
  }
  #playHub.homeActive #hubHome .hubHeading > h1 {
    grid-column: 1; grid-row: 1; font-size: clamp(44px, 6vw, 78px);
    letter-spacing: -.06em; line-height: 1;
  }
  #playHub.homeActive #hubHome .hubHeading > p {
    grid-column: 1; grid-row: 2; color: var(--web-muted); font-size: 17px;
  }
  #playHub.homeActive #hubHome .homeWelcomeRow { grid-column: 2; grid-row: 1 / 3; }
  #playHub.homeActive #hubHome .homeOptions { grid-template-columns: repeat(3,minmax(0,1fr)); }
  #playHub.homeActive #hubHome .homeOptions strong { font-size: 21px; }
  #gameOverview:not([hidden]) { width: min(calc(100% - 40px), 1160px); }
  #gameOverview .overviewScroll {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
    align-content: start; align-items: start; gap: 16px 28px; padding: 24px;
  }
  #gameOverview :is(.overviewHeading,.overviewPlayers,.overviewProgress,.overviewFootnote) { grid-column: 1; margin: 0; }
  #gameOverview .overviewHeading { text-align: left; }
  #gameOverview .overviewHeading h1 { font-size: clamp(28px, 3vw, 44px); letter-spacing: -.045em; }
  #gameOverview .overviewPlayer { padding: 18px 10px; }
  #gameOverview .web-move-breakdown { grid-column: 2; grid-row: 1 / 6; }
  #gameOverview .web-move-breakdown .overviewCount { min-height: 32px; }
  #gameOverview .overviewActions { padding-inline: 24px; }
}
@media (min-width: 900px) and (min-height: 600px) and (orientation: landscape) {
  #boardWorkspace .boardColumn {
    --board-size: min(53vw, 700px, calc(100dvh - 142px));
    grid-template-rows: 14px 28px auto auto minmax(0,1fr) 28px;
    gap: 8px 24px;
  }
  #boardWorkspace .boardWrap { grid-row: 3 / 6; align-self: start; }
  #boardWorkspace .boardColumn > .player:nth-child(5) { grid-row: 6; }
  #boardWorkspace .boardColumn > .compactCoach {
    grid-row: 2 / 4; align-self: start; height: auto;
    min-height: 0; padding: 0;
  }
  #boardWorkspace .compactCoach .coachBubble {
    min-height: 0; height: auto; padding: 18px; border-radius: var(--web-radius);
  }
  #boardWorkspace .boardColumn > .boardControls {
    grid-row: 4; align-self: start; margin: 0; min-height: 0;
  }
  #boardWorkspace .boardColumn > .reviewToolbar {
    grid-row: 5; align-self: start; min-height: 0;
  }
}

:is(#settingsPanel,#importPanel,#reviewPanel) .sheetHeading {
  padding-bottom: 10px; border-bottom: 1px solid var(--web-border);
}
:is(#settingsPanel,#importPanel) :is(input:not([type="checkbox"]),textarea,select) {
  border-radius: 8px;
}
#manualImport textarea { min-height: 110px; line-height: 1.45; }
:is(#lessonList,#savedGamesPage,#playSetup,#onlineLobby) :is(h1,h2,h3) {
  letter-spacing: -.025em;
}
:is(.lessonCard,.savedGame,.botCards button) {
  border-color: var(--web-border);
}
:is(.lessonCard,.botCards button):hover { border-color: var(--web-accent); }
.web-voice-settings { min-inline-size: 0; border: 1px solid var(--web-border); border-radius: 12px; padding: 12px; }
@media (min-width: 900px) and (min-height: 600px) and (orientation: landscape) {
  #playScreen { grid-template-rows: 48px 40px auto auto auto 24px minmax(0,1fr) 28px; gap: 10px 24px; }
  #playScreen #playBoard, #playScreen .playPlayer { width: min(100%, 700px, calc(100dvh - 162px)); }
  #playScreen > #playBoard { align-self: start; }
  #playScreen > #playMoves { align-self: stretch; max-height: min(32dvh, 240px); }
  #playScreen #playReview:not(:disabled) { background: var(--web-accent); color: var(--web-base); }
  #playScreen #playSave { background: var(--web-raised); color: var(--web-text); }
}

.web-information { margin: 0; color: var(--web-text); line-height: 1.6; }
.web-information main { max-width: 720px; padding: 32px 20px; margin-inline: auto; }
.web-information section { background: var(--web-surface); padding: 16px 20px; border: 1px solid var(--web-border); border-radius: 16px; margin-block: 16px; }
.web-information a, .web-online-link { color: var(--web-accent); }
.web-online-link { display: inline-block; padding: 10px 14px; border: 1px solid var(--web-border); border-radius: 10px; }

#hubHome .hubHeading > .homeLogo {
  grid-area: mark;
  width: clamp(60px, 8vw, 116px);
  height: auto;
  aspect-ratio: 1;
  max-width: none;
  padding: 0;
}
#hubHome .hubHeading > .homeLogo img { width: 100%; height: 100%; display: block; }
@media (min-width: 850px) and (min-height: 580px) {
  #playHub.homeActive #hubHome .hubHeading {
    grid-template-columns: auto minmax(0,1fr) auto;
    grid-template-areas: "mark title greeting" "mark tagline greeting";
    column-gap: clamp(14px, 2vw, 28px);
  }
  #playHub.homeActive #hubHome .hubHeading > h1 {
    grid-area: title; font-size: clamp(36px, 5vw, 70px);
  }
  #playHub.homeActive #hubHome .hubHeading > p { grid-area: tagline; }
  #playHub.homeActive #hubHome .homeWelcomeRow { grid-area: greeting; }
  #learnScreen:not(.lessonActive) {
    padding-inline: max(22px, calc((100vw - 1220px)/2));
  }
  #learnScreen:not(.lessonActive):not([hidden]) {
    display: grid;
    grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
    align-content: start;
    align-items: start;
    column-gap: 24px;
  }
  #learnScreen:not(.lessonActive) > .playHeading { grid-column: 1 / -1; }
  #learnScreen:not(.lessonActive) #lessonFilters { grid-column: 1; }
  #learnScreen:not(.lessonActive) #lessonList { grid-column: 2; }
  #learnScreen:not(.lessonActive) :is(#lessonFilters,#lessonList,.playHeading) {
    width: 100%; max-width: none;
  }
  #lessonCategoryTabs { display: flex; flex-wrap: wrap; }
  #lessonCategoryTabs > button { flex: 0 1 auto; padding-inline: 16px; }
  #lessonList { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; }
  #lessonList .lessonCard { padding-block: 14px; }
}

.web-game-return { display: grid; gap: 8px; margin-block: 20px; }
.web-game-return label { display: grid; gap: 6px; }
.web-game-return p:empty { display: none; }
@media (min-width: 900px) and (min-height: 600px) and (orientation: landscape) {
  #boardWorkspace .boardColumn {
    --board-size: min(calc(100vw - 395px), 1000px, calc(100dvh - 144px));
    grid-template-columns: var(--board-size) minmax(0, 430px);
    width: min(calc(100% - 40px), 1480px); max-width: none; justify-content: center;
  }
  #playScreen {
    --web-play-board: min(1000px, calc(100dvh - 144px), calc(100vw - 355px));
    grid-template-columns: var(--web-play-board) minmax(0, 430px);
    max-width: 1480px; justify-content: center;
  }
  #playScreen #playBoard, #playScreen .playPlayer { width: 100%; }
  #learnScreen.lessonActive {
    --lesson-board: min(1000px, calc(100dvh - 92px), calc(100vw - 355px));
  }
  #learnScreen.lessonActive #lessonWorkspace {
    grid-template-columns: var(--lesson-board) minmax(0, 430px);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
    align-items: start; justify-content: center;
  }
  #learnScreen.lessonActive #lessonBoard { align-self: start; }
  #learnScreen.lessonActive .lessonCoach { min-height: 0; height: auto; }
  #learnScreen.lessonActive #lessonFeedback { min-height: 0; margin: 0; }
}

/* Home and online lobby share a quiet typographic hierarchy. */
#hubHome .homeWelcomeRow { min-width: 0; }
#hubHome #homeMessage {
  width: auto; min-width: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none;
}
#hubHome #homeMessage::before, #hubHome #homeMessage::after { display: none; }
#hubHome .homeGreeting { color: var(--web-muted); font-size: 15px; font-weight: 600; }
#hubHome .homeMessageText { display: block; margin-top: 4px; color: var(--web-text); font-size: 14px; line-height: 1.4; }
#hubHome #homeMessage:not([hidden]) {
  position: relative; display: inline-block; max-width: min(100%, 380px);
  padding: 9px 14px; border: 1px solid var(--web-border); border-radius: 13px;
  background: var(--web-surface);
}
#hubHome #homeMessage:not([hidden])::before {
  content: ''; position: absolute; display: block; width: 9px; height: 9px;
  left: -5px; top: 16px; transform: rotate(45deg);
  border: solid var(--web-border); border-width: 0 0 1px 1px;
  background: var(--web-surface);
}
.web-zen-controls { display: grid; gap: 8px; margin-top: 10px; }
#onlineLobby #onlineBrowserSession:not([hidden]) {
  padding: 14px; border: 1px solid var(--web-border); border-radius: 12px;
  background: var(--web-raised);
}
@media (min-width: 850px) and (min-height: 580px) {
  #playHub.homeActive #hubHome .hubHeading {
    grid-template-columns: auto minmax(0,1fr);
    grid-template-areas: "mark greeting" "mark title" "mark tagline";
    align-items: center;
  }
  #playHub.homeActive #hubHome .homeWelcomeRow:has(#homeMessage[hidden]) { display: none; }
}
#onlinePanel:has(#onlineLobby:not([hidden])) {
  padding: clamp(16px, 3vw, 32px);
  background: var(--web-base);
}
#onlinePanel:has(#onlineLobby:not([hidden])) > .playHeading,
#onlineLobby { width: min(100%, 1100px); margin-inline: auto; }
#onlineLobby:not([hidden]) {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 18px; align-items: start; margin-block: 22px;
}
.web-online-main, .web-online-side {
  min-width: 0; padding: clamp(14px, 2.1vw, 26px);
  border: 1px solid var(--web-border); border-radius: var(--web-radius);
  background: var(--web-surface);
}
.web-online-side { display: grid; gap: 12px; }
#onlineLobby #onlineSetupTitle { margin-block: 0 6px; font-size: clamp(28px, 4vw, 43px); letter-spacing: -.04em; }
#onlineLobby :is(#onlineAccount,#onlineTimeNote,#onlineSignupHelp) { color: var(--web-muted); }
#onlineLobby #onlineStatus { margin-block: 6px 14px; }
#onlineLobby .friendTabs { margin-block: 6px 12px; }
#onlineLobby .onlineMatchActions { margin-top: 12px; }
#onlineLobby #onlineSeek { width: auto; min-width: 145px; }
#onlineLobby #onlineRatings { margin: 0; }
#onlineLobby :is(#onlineAccountMore,#onlineReconnect,#friendIncoming) { min-height: 40px; }
.web-online-return { padding-top: 12px; border-top: 1px solid var(--web-border); }
.web-online-return h2 { font-size: 17px; margin: 0 0 8px; }
.web-online-return .web-game-return { margin-block: 0 8px; }
.web-online-return input {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--web-border); border-radius: 8px;
  background: var(--web-base); color: var(--web-text);
}
.web-online-links { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.web-online-links .web-online-link { border: 0; padding: 6px 0; font-size: 14px; }
@media (max-width: 760px) {
  #onlineLobby:not([hidden]) { grid-template-columns: minmax(0,1fr); gap: 12px; margin-top: 12px; }
}

[data-web-test-ads] :is(#pinCreditWidget,#subscriptionNotice,#restorePurchases,#manageSubscription,#changeAgeGroup,#adPrivacy,#exportAdDiagnostics) {
  display: none !important;
}
.web-test-ad::backdrop { background: #100d0bc9; }

/* Keep in-flight piece animations inside the board when the viewport changes. */
#playBoard { overflow: clip; }

#lessonWorkspace .lessonVoiceRow { container-type: inline-size; }
@container (max-width: 365px) {
  #lessonWorkspace #lessonModeSegment { display: flex; flex: 1; min-inline-size: 0; }
  #lessonWorkspace #lessonModeSegment > button {
    flex: 1; min-inline-size: 0; padding-inline: 4px;
  }
  #lessonWorkspace .lessonVoiceRow :is(#lessonPlanToggle,#lessonSpeak) {
    min-inline-size: 0; padding-inline: 6px;
  }
  #lessonWorkspace .lessonVoiceMessages:not(:has(> p:not(:empty))) { display: none; }
}

/* Let short lesson workspaces flow rather than stacking actions over each other. */
@media (orientation: portrait) and (max-width: 430px) {
  #learnScreen.lessonActive {
    --lesson-board: min(calc(100vw - 16px), max(220px, calc(100dvh - 420px)));
    overflow-y: auto;
  }
  #learnScreen.lessonActive #lessonWorkspace {
    flex: none; grid-template-rows: auto 140px auto var(--lesson-board) auto auto auto;
    align-content: start; gap: 6px;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  #learnScreen.lessonActive { overflow-y: auto; }
  #learnScreen.lessonActive #lessonWorkspace {
    flex: none; grid-template-rows: auto minmax(104px, auto) auto auto auto auto;
    align-content: start;
  }
  #learnScreen.lessonActive #lessonBoard { align-self: start; }
}


.web-android-download {
  align-self: flex-start; display: inline-flex; align-items: center;
  min-height: 44px; max-width: 100%; padding: 6px 12px;
  border: 1px solid var(--web-border); border-radius: 10px;
  color: var(--web-accent); font-size: 14px; line-height: 1.35;
  text-underline-offset: 3px;
}
.web-android-download:hover { background: var(--web-raised); }
