@import url('./webfonts/fonts.css');
:root {
  --classroom-font: var(--cw-font-body);
}
/* Readable UI text in both languages; retain dedicated icon fonts and canvas art. */
html body,
html body :where(button, input, textarea, select, option, h1, h2, h3, h4, p, label, a, li, td, th),
html body :where(span, div):not([class*="icon"]):not([class*="fa-"]) {
  font-family: var(--classroom-font) !important;
}
html[lang^="zh"] :where(input, textarea, p, label) { line-height: 1.6; }
/* Keep device cards inside small screens; preserve the existing controls/colors. */
.enableCameraScene { width: 100%; box-sizing: border-box; }
.enableCameraScene > section > div { width: 100%; min-width: 0; }
.enableCameraScene [class~="min-w-[300px]"] { min-width: 0; width: min(100%, 450px); margin-inline: 0; }
.enableCameraScene section.text-center p { display: block; width: min(100%, 44rem); opacity: .85; }
/* Display names can contain Chinese in either interface language. */
.username-display p { font-family: var(--classroom-font) !important; }
html body :is(h1,h2,h3,h4,h5,h6), html body :is(h1,h2,h3,h4,h5,h6) :is(span,div), .cw-classroom-ui [data-cw-device-panel] :is(h2,h3), #cw-microphone-panel > summary { font-family: var(--cw-font-heading) !important; }
#classroom-language {
  position: fixed; bottom: .75rem; right: 4rem; z-index: 2147483000;
  display: flex; gap: .125rem;
  padding: .25rem; background: #182831ee;
  border: 1px solid #ffffff40; border-radius: 6px;
  color: #ffffff; font: 14px/1.4 var(--classroom-font);
}
#classroom-language button {
  min-height: 36px; padding: .375rem .625rem; border: 0; border-radius: 4px;
  background: transparent; color: #ffffff; cursor: pointer;
  font: inherit; font-family: var(--classroom-font) !important;
}
#classroom-language button[aria-pressed="true"] { background: #3d5966; }
#classroom-language button:hover { background: #496573; }
#classroom-language button:focus-visible { outline: 3px solid #ffce65; outline-offset: 2px; }
@media (max-width: 480px) {
  #classroom-language { bottom: calc(4.5rem + env(safe-area-inset-bottom)); right: 4rem; font-size: 12px; }
  #classroom-language button { min-height: 44px; }
  /* Character selection and device setup fill the viewport on phones; lift the
     language bar above their action rows so the main buttons stay clickable. */
  body:has(.selectCharacterSceneFormSubmit) #classroom-language,
  body:has(.enableCameraScene) #classroom-language { bottom: calc(7.5rem + env(safe-area-inset-bottom)); }
}
/* Setup scenes overflow tiny viewports (extra-narrow width or split-screen
   height); a fixed bar cannot avoid their controls there, so hide it until
   the game loads. The entry page only hides at split-screen heights, so
   extra-narrow phones can still switch language before entering. */
@media (max-height: 380px) {
  body:has(.loginScene) #classroom-language { display: none; }
}
@media (max-width: 360px), (max-height: 380px) {
  body:has(.selectCharacterSceneFormSubmit) #classroom-language,
  body:has(.enableCameraScene) #classroom-language { display: none; }
}

/* Quality labels need their own width: the upstream absolute labels collapse
   to the antenna icon's width and wrap Chinese characters onto separate lines. */
.cw-quality-control { padding: 1.25rem 1.5rem 2rem; margin: 0; }
.cw-quality-control > div { width: min(100%, 42rem); min-width: 0; }
.cw-quality-options {
  display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem; padding: 0; margin: 0 0 1rem;
}
.cw-quality-options > li {
  display: flex !important; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: .25rem; min-width: 0;
}
.cw-quality-label {
  position: static; display: block; white-space: nowrap; min-height: 2.75rem;
  padding: .25rem .5rem; border: 0; background: transparent; color: inherit;
  font: inherit; line-height: 1.5; cursor: pointer;
}
.cw-quality-label:focus-visible, .cw-message-send:focus-visible {
  outline: 3px solid #ffce65; outline-offset: 3px; border-radius: .25rem;
}

/* Keep the announcement editor and actions aligned in both interface languages. */
.cw-global-message { display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem; min-width: 0; }
.cw-global-message .global-message-subOptions { margin: 0; }
.cw-global-message .global-message-subOptions > section { flex-wrap: wrap; padding: 0; }
.cw-global-message .global-message-subOptions button { padding: .75rem 1.5rem; min-height: 2.75rem; }
.cw-global-message .global-message-content { min-width: 0; }
:is(.cw-global-message, .cw-message-dialog) section.section-input-send-text { height: auto; }
:is(.cw-global-message, .cw-message-dialog) section.section-input-send-text .input-send-text { height: auto; overflow: visible; }
:is(.cw-global-message, .cw-message-dialog) .ql-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; max-height: none !important; }
:is(.cw-global-message, .cw-message-dialog) .ql-toolbar .ql-formats { margin-right: .5rem; }
:is(.cw-global-message, .cw-message-dialog) .ql-editor { min-height: 10rem; max-height: 40vh; overflow-y: auto; }
.cw-message-dialog { gap: 1rem; min-width: 0; }
.cw-message-dialog > .flex:last-child { justify-content: flex-end; }
.cw-message-dialog .btn-light { background: var(--color-secondary, #4056f6); color: #fff; border: 1px solid #879fc2; }
.cw-message-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.cw-message-scope { display: inline-flex; align-items: flex-start; gap: .625rem; margin: 0; line-height: 1.5; }
.cw-message-scope input { flex: 0 0 auto; width: 1.125rem; height: 1.125rem; margin: .1875rem 0 0; accent-color: #4056f6; }
.cw-message-actions .centered-column { margin: 0; }
.cw-message-send {
  min-height: 2.75rem; padding: .625rem 1.5rem; border: 1px solid #879fc2;
  border-radius: .5rem; background: var(--color-secondary, #4056f6); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.cw-message-send:hover { filter: brightness(1.12); }
.cw-message-send:disabled { opacity: .5; cursor: default; }
html[lang^="zh"] :is(.cw-global-message, .cw-message-dialog) .ql-picker.ql-header .ql-picker-label:not([data-value])::before { content: "正文"; }
html[lang^="zh"] :is(.cw-global-message, .cw-message-dialog) .ql-picker.ql-size .ql-picker-label:not([data-value])::before { content: "标准字号"; }
html[lang^="zh"] :is(.cw-global-message, .cw-message-dialog) .ql-picker.ql-font .ql-picker-label:not([data-value])::before { content: "无衬线"; }
@media (max-width: 600px) {
  .cw-quality-control { padding: 1rem .75rem 1.5rem; }
  .cw-global-message { padding: .75rem; gap: 1rem; }
  .cw-message-actions { align-items: stretch; }
  .cw-message-actions .centered-column, .cw-message-send { width: 100%; }
}

/* Bound the native tab prompt to the viewport; keep its action above the language bar. */
.cw-tab-popup { width: min(28rem, calc(100vw - 2rem)); min-width: 0; max-width: calc(100vw - 2rem); box-sizing: border-box; }
.cw-tab-popup > div:first-child { min-width: 0; padding: .75rem 1rem; }
.cw-tab-popup .responsive-message { font-size: 14px !important; line-height: 1.6 !important; white-space: normal; overflow-wrap: anywhere; padding-bottom: 0 !important; }
.cw-tab-popup .buttons-wrapper button { width: 100%; max-width: none; min-height: 44px; padding: .625rem .875rem; font-size: 16px !important; scale: 1; box-sizing: border-box; }
@media (max-width: 480px) {
  .cw-tab-popup { margin-bottom: calc(7.5rem + env(safe-area-inset-bottom)); }
}
