@font-face {
  font-family: Inter;
  src: url("/assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  color: #28303f;
  background: #f0f3f5;
  font: 400 16px / 1.5 Inter, sans-serif;
  --ink: #28303f;
  --surface: #f0f3f5;
  --paper: #fff;
  --yellow: #ffc800;
  --yellow-hover: #f2bd00;
  --yellow-soft: #fff3c4;
  --secondary: #5b687c;
  --line: #dce2e8;
  --error: #9d2528;
  --radius: 24px;
  --pill: 100vmax;
  --reading-width: 784px;
  --gutter: clamp(16px, 4vw, 52px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, ol, ul { margin: 0; }
button, input, textarea { color: inherit; font: inherit; }
button { padding: 0; border: 0; background: none; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
}

:focus-visible {
  outline: 2px solid #53637b;
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  --drawer-width: min(297px, calc(100% - 48px));
}

.chat, .chat-body, .games-area, .game-session {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat {
  height: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  transition: transform 220ms ease;
}

.chat-body, .games-area, .game-session { flex: 1 1 auto; }

.chat-header {
  flex: none;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-brand, .auth-brand, .history-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.layout-switch {
  position: relative;
  isolation: isolate;
  display: grid;
  flex: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 9rem;
  min-height: 44px;
  padding: 4px;
  border-radius: var(--pill);
  background: #e4e9ef;
  color: #4e5c70;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}

.layout-switch label {
  display: grid;
  place-items: center;
  border-radius: var(--pill);
  cursor: pointer;
  text-align: center;
}

.layout-switch input:focus-visible + label { outline: 2px solid #53637b; }
.layout-switch input:checked + label { color: var(--ink); }

.layout-switch::before {
  position: absolute;
  z-index: -1;
  inset: 4px auto 4px 4px;
  width: calc(50% - 4px);
  border-radius: inherit;
  background: var(--paper);
  box-shadow: 0 1px 2px rgb(40 48 63 / 15%);
  content: '';
  transition: transform 160ms ease, background-color 160ms ease;
}

.layout-switch:has(#layout-reading:checked)::before {
  transform: translateX(100%);
  background: var(--yellow);
}

.round {
  flex: none;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
}

.workspace-nav {
  display: flex;
  grid-area: 2 / 1 / 3 / -1;
  gap: 4px;
  padding: 3px;
  border-radius: var(--pill);
  background: var(--surface);
}

.workspace-tab {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 6px 16px;
  border-radius: var(--pill);
  color: var(--secondary);
  font-size: 14px;
  font-weight: 580;
}

.workspace-tab[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(40 48 63 / 12%);
}

@media (hover: hover) {
  .round:hover, .workspace-tab:hover:not([aria-pressed="true"]) { background: #e4e9ee; }
}
.round:active { background: #dfe6ed; }

.welcome, .conversation, .games-catalog {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #bcc6d1 transparent;
}

.welcome {
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 4dvh, 44px) var(--gutter) 16px;
}

.welcome-inner {
  container: welcome / inline-size;
  width: min(100%, var(--reading-width));
  margin: auto;
}

.welcome-intro {
  display: grid;
  justify-items: start;
  gap: 15px;
}

.welcome-mark {
  display: grid;
  width: 76px;
  height: 64px;
  place-items: center;
  border-radius: 28px 28px 28px 10px;
  background: var(--yellow);
}

.welcome-mark img { width: 37px; height: auto; }

.welcome-copy h1, .admin-content > h1 {
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 640;
  line-height: 1.08;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.welcome-copy p {
  max-width: 38ch;
  margin-top: 10px;
  color: var(--secondary);
  font-size: 16px;
  line-height: 1.5;
}

.prompt-section { margin-top: 24px; }

.prompt-section h2 {
  margin-bottom: 10px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 580;
}

.prompts { display: grid; gap: 8px; }

.prompt {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  text-align: left;
  font-size: 14px;
  font-weight: 560;
  line-height: 1.3;
}

.prompt-featured {
  border-color: transparent;
  background: var(--yellow-soft);
}

.prompt-arrow { width: 16px; height: 16px; color: var(--secondary); }

@media (hover: hover) {
  .prompt:hover { border-color: #abb8c8; }
  .prompt-featured:hover { border-color: transparent; background: #ffe68d; }
}
.prompt:active { background: #e7edf2; }
.prompt-featured:active { background: #ffe68d; }

@container welcome (min-width: 620px) {
  .welcome-intro {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 30px;
  }

  .welcome-copy { grid-area: 1 / 1; }
  .welcome-copy h1 { font-size: clamp(44px, 7.7cqi, 64px); }
  .welcome-copy p { margin-top: 14px; font-size: 18px; }

  .welcome-mark {
    grid-area: 1 / 2;
    width: 150px;
    height: 128px;
    border-radius: 56px 56px 56px 18px;
  }

  .welcome-mark img { width: 75px; }
  .prompt-section { margin-top: 38px; }
  .prompts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .prompt { min-height: 60px; }
}

.conversation {
  padding: clamp(18px, 4dvh, 44px) var(--gutter) 16px;
  scroll-padding-block: 12px;
}

.conversation:focus-visible { outline-offset: -3px; }

.messages, .history-list { padding: 0; list-style: none; }

.messages, .waiting, .request-error {
  max-width: var(--reading-width);
  margin-inline: auto;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user-message {
  align-self: end;
  max-width: min(88%, 560px);
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 21px 21px 5px 21px;
  background: var(--paper);
}

.assistant-message {
  width: min(100%, 66ch);
  font-size: 16px;
  line-height: 1.6;
}

#messages { line-height: 1.6; }
#messages > .message { font: inherit; }

.chat-transcript .assistant-message { white-space: normal; }
.chat-transcript .assistant-message > p { white-space: pre-wrap; }

.reply-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 650;
}

.reply-author .brand-mark {
  width: 27px;
  height: 27px;
  border-radius: 10px 10px 10px 4px;
}

.reply-author img { width: 15px; height: auto; }

.message-sources {
  margin-top: 12px;
  padding-inline-start: 20px;
  font-size: 14px;
  white-space: normal;
}

.message-sources a {
  color: inherit;
  text-underline-offset: 3px;
}

.waiting, .request-error { margin-top: 16px; }
.waiting { color: var(--secondary); font-size: 14px; }
.waiting:empty { display: none; }

.request-error {
  padding: 12px 14px;
  border: 1px solid #edcfd0;
  border-radius: 16px;
  background: #fff7f7;
  color: var(--error);
}

.retry { margin-top: 8px; }

.composer-panel {
  flex: none;
  padding: 8px var(--gutter) max(14px, var(--safe-bottom));
  background: var(--surface);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: min(100%, var(--reading-width));
  min-height: 62px;
  margin-inline: auto;
  padding: 8px 8px 8px 17px;
  border: 1px solid #cbd4de;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 6px 20px rgb(40 48 63 / 6%);
}

.composer:focus-within {
  border-color: #7b8ca4;
  box-shadow: 0 0 0 2px rgb(83 99 123 / 13%);
}

.composer textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: min(126px, 22dvh);
  padding: 10px 0;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  field-sizing: content;
}

.composer textarea::placeholder, .search-field input::placeholder {
  color: var(--secondary);
  opacity: 1;
}

.composer-button {
  flex: 0 0 44px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 17px;
}

.send { background: var(--yellow); }
.send:disabled { color: #657287; background: var(--surface); }

@media (hover: hover) {
  .send:hover:not(:disabled) { background: var(--yellow-hover); }
}

.send-icon {
  position: relative;
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: currentColor;
}

.send-icon::before {
  position: absolute;
  top: 1px;
  left: -4px;
  width: 10px;
  height: 10px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
  border-radius: 1px;
  content: "";
  transform: rotate(-45deg);
}

.disclaimer {
  margin-top: 8px;
  color: var(--secondary);
  text-align: center;
  font-size: 12px;
  line-height: 1.35;
}

.scrim {
  position: absolute;
  z-index: 2;
  inset: 0 0 0 var(--drawer-width);
  background: rgb(40 48 63 / 25%);
  cursor: pointer;
}

.history-open .chat {
  border-radius: 24px 0 0 24px;
  transform: translateX(var(--drawer-width));
}

.history {
  position: absolute;
  z-index: 3;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: var(--drawer-width);
  min-width: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, var(--safe-bottom));
  overflow: hidden;
  outline: none;
  background: var(--paper);
  visibility: hidden;
  transform: translateX(-100%);
  transition: transform 220ms ease, visibility 220ms;
}

.history-open .history { visibility: visible; transform: translateX(0); }

.history-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-header h2 {
  font-size: 22px;
  font-weight: 630;
  letter-spacing: -.04em;
}

.history-back .icon { width: 18px; height: 18px; }

.search-field {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-inline: 12px;
  border: 1px solid transparent;
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--secondary);
}

.search-field:focus-within { border-color: #7b8ca4; }
.search-field .icon { width: 20px; height: 20px; }

.search-field input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.history-conversations {
  flex: 1 1 auto;
  min-height: 0;
  padding: 3px 3px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.history-conversations h3 {
  margin: 5px 5px 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.history-empty {
  margin: 8px 5px;
  color: var(--secondary);
  font-size: 14px;
}

.history-entry {
  position: relative;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px 8px 34px;
  overflow: hidden;
  border-radius: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.history-entry::before {
  position: absolute;
  top: calc(50% - 7px);
  left: 10px;
  width: 15px;
  height: 13px;
  border: 1.4px solid #66748a;
  border-radius: 5px 5px 5px 1px;
  content: "";
}

.history-entry:hover { background: var(--surface); }
.history-entry[aria-current="true"] { background: var(--yellow-soft); }
.history-entry:focus-visible { outline-offset: -2px; }

.history-footer {
  flex: none;
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.profile-initial, .brand-mark {
  flex: none;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow-soft);
  font-weight: 650;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px 14px 14px 5px;
  background: var(--yellow);
}

.profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 580;
}

.history-footer .account-button { flex: 1 1 auto; }
.new-chat { flex: none; width: 100%; }

.auth-shell, .admin-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) var(--gutter) max(20px, var(--safe-bottom));
}

.account-card {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: clamp(18px, 5vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.auth-shell .account-card {
  width: min(100%, 440px);
  gap: 24px;
  box-shadow: 0 16px 45px rgb(40 48 63 / 7%);
}

.account-form, .admin-create, .admin-edit { display: grid; gap: 12px; }
.account-form > p, #auth-status, #users-status { color: var(--secondary); font-size: 14px; }
.account-form > p { margin: -4px 0 6px; }

.account-card h1 {
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 640;
  line-height: 1.12;
  letter-spacing: -.045em;
}

.account-card h2 {
  font-size: 20px;
  font-weight: 630;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.account-card label {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 14px;
  font-weight: 560;
}

.account-card input:not([type="hidden"]) {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid #b9c4d1;
  border-radius: 13px;
  background: var(--paper);
  font-size: 16px;
  font-weight: 400;
}

.account-card input[readonly] { background: var(--surface); }

.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--pill);
  background: var(--surface);
  color: inherit;
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.account-button.primary { background: var(--yellow); }

@media (hover: hover) {
  .account-button:hover:not(:disabled) { background: #e4e9ee; }
  .account-button.primary:hover:not(:disabled) { background: var(--yellow-hover); }
}

.account-button:disabled { opacity: .58; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-error { color: var(--error); font-size: 14px; }

.admin-content {
  display: grid;
  gap: 16px;
  width: min(100%, 960px);
  margin-inline: auto;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(36px, var(--safe-bottom));
}

.admin-content > h1 { margin-block: 10px 4px; }
.admin-header { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-header, .admin-user-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-heading { flex-wrap: wrap; overflow-wrap: anywhere; }
.admin-users { display: grid; gap: 18px; padding: 0; list-style: none; }
.admin-user { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.user-status { padding: 4px 9px; border-radius: var(--pill); background: var(--surface); color: var(--secondary); font-size: 13px; }
.credential { border-color: #e3c45c; background: #fff9e6; }

.chat-header.scenario-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
}

.scenario-header #scenario-back { grid-area: 1 / 1; }
.scenario-header #game-title {
  grid-area: 1 / 2;
  overflow: hidden;
  font-size: 16px;
  font-weight: 550;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scenario-header #return-chat { grid-area: 1 / 3; }

.games-catalog { padding: clamp(20px, 4dvh, 44px) var(--gutter) 32px; }
.catalog-inner { width: min(100%, 944px); margin-inline: auto; }
.catalog-inner > h1, .games-catalog-heading h1 {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 560;
  line-height: 1.12;
  letter-spacing: -.035em;
}
.catalog-inner > h1:focus, .games-catalog-heading h1:focus { outline: none; }

.games-catalog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-character-button { background: var(--paper); }
.game-character-button .icon { width: 20px; height: 20px; }

.category-grid, .games-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
  padding: 0;
  list-style: none;
}

.category-tile, .game-tile {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: end;
  width: 100%;
  overflow: hidden;
  padding: 16px;
  border-radius: var(--radius);
  background: #273145;
  color: white;
  text-align: left;
}

.category-tile { aspect-ratio: 1; }
.game-tile {
  height: 100%;
  min-height: 232px;
  aspect-ratio: 8 / 7;
}

.category-tile img, .game-tile img {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.category-tile::after, .game-tile::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, rgb(10 14 23 / 92%) 0%, rgb(10 14 23 / 62%) 29%, transparent 74%);
  content: "";
}

.tile-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
  padding-right: 38px;
  overflow-wrap: anywhere;
}

.category-tile .tile-copy {
  padding-right: 0;
  font-size: clamp(16px, 3vw, 25px);
  font-weight: 620;
  line-height: 1.12;
  letter-spacing: -.02em;
}
.category-tile:has(.tile-arrow) .tile-copy { padding-right: 40px; }
.category-tile small { font-size: 13px; font-weight: 500; letter-spacing: 0; }

.game-tile-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -.025em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 3px;
}

.game-tags > span {
  padding: 3px 8px;
  border-radius: var(--pill);
  background: rgb(12 18 31 / 83%);
  color: var(--paper);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.game-tile-description {
  display: -webkit-box;
  overflow: hidden;
  color: #f0f3f5;
  font-size: 14px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tile-arrow {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 50%;
  background: rgb(255 255 255 / 94%);
  color: var(--ink);
}

.game-resume {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: var(--pill);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
}

.game-tile:active, button.category-tile:active { filter: brightness(.9); }

@media (hover: hover) {
  .game-tile:hover .tile-arrow, button.category-tile:hover .tile-arrow { background: var(--yellow); }
}

.game-preview {
  position: fixed;
  width: min(480px, calc(100% - var(--preview-gutters, 32px)));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 28px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 16px 52px rgb(20 27 40 / 23%);
}

.game-preview[open] { display: flex; flex-direction: column; }
.game-preview::backdrop { background: rgb(22 28 42 / 56%); }

.game-preview-close {
  position: absolute;
  z-index: 1;
  top: 20px;
  right: 20px;
  background: var(--paper);
}

.game-preview-body {
  min-height: 0;
  padding: 12px 12px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.game-preview-cover {
  width: 100%;
  height: clamp(100px, 22dvh, 180px);
  border-radius: 18px;
  background: #273145;
  object-fit: cover;
  object-position: center 14%;
}

.game-preview-copy { padding: 16px 8px 4px; }
.game-preview-copy h2 {
  overflow-wrap: anywhere;
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -.03em;
}

.game-preview-stats {
  margin-block: 14px;
  padding: 9px 12px 11px;
  border-radius: 16px;
  background: var(--surface);
}

.game-preview-stats p {
  color: var(--secondary);
  font-size: 12px;
}

.game-preview-stats dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 5px 0 0;
}

.game-preview-stats dt { color: var(--secondary); font-size: 13px; }
.game-preview-stats dd {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 26px;
}

.game-preview-description { overflow-wrap: anywhere; font-size: 16px; line-height: 1.5; }
.game-preview-description p + p { margin-top: 10px; }

.game-preview-actions { flex: none; padding: 12px 20px 20px; }
.game-preview-actions .account-button { width: 100%; min-height: 52px; font-size: 16px; }

.game-character { width: min(420px, calc(100% - var(--preview-gutters, 32px))); }
.game-character form { display: flex; flex-direction: column; min-height: 0; }

.game-character-body {
  min-height: 0;
  padding: 24px 20px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.game-character h2 {
  padding-right: 52px;
  font-size: 26px;
  font-weight: 600;
  line-height: 36px;
  letter-spacing: -.03em;
}

.game-character .game-preview-close { background: var(--surface); }
.game-character-hint { margin-top: 8px; color: var(--secondary); font-size: 14px; line-height: 20px; }
.game-character-fields, .game-character-gender { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.game-character-fields { display: grid; gap: 16px; margin-top: 20px; }
.game-character-gender legend { margin: 0 0 6px; padding: 0; font-weight: 550; }
.game-character-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

.game-character-options label {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface);
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

.game-character-options label:has(:checked) { border-color: var(--yellow); background: var(--yellow-soft); font-weight: 600; }
.game-character-options label:has(:focus-visible) { outline: 2px solid #53637b; outline-offset: 2px; }
.game-character-field { display: grid; gap: 6px; font-weight: 550; }

.game-character-field input, .game-character-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-weight: 400;
  line-height: 22px;
}

.game-character-field textarea { resize: vertical; }
.game-character-limit { margin-top: -10px; font-size: 13px; }
.game-character .account-error, #game-character-loading { margin-top: 16px; }

.catalog-credits {
  margin-top: 24px;
  color: var(--secondary);
  font-size: 13px;
}
.catalog-credits ul { padding: 8px 0 0 18px; }
.catalog-credits li + li { margin-top: 8px; }
.catalog-credits a { color: inherit; text-underline-offset: 3px; }

.message > .account-button { display: block; margin-top: 12px; }

.chat.reading-layout { background: var(--paper); }
.reading-layout #chat-body { --reading-width: 40rem; }
.reading-layout #messages {
  gap: 24px;
  font-size: 1.0625rem;
  line-height: 1.59;
}

.reading-layout #chat-body .assistant-message {
  width: 100%;
  padding: 0;
  color: #202632;
}

.reading-layout #chat-body .reply-author { display: none; }
.reading-layout #chat-body .user-message {
  max-width: min(87%, 34rem);
  border: 0;
  border-radius: 20px;
  background: #eff2f7;
}

.reading-layout #chat-body .composer-panel { background: var(--paper); }

.reading-layout .reply-content > * + * { margin-block-start: 1em; }
.reading-layout .reply-content :is(h1, h2, h3, h4, h5, h6) {
  margin-block: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.35;
}

.reading-layout .reply-content :is(h1, h2) { font-size: 1.25rem; }
.reading-layout .reply-content > * + :is(h1, h2, h3, h4, h5, h6) { margin-block-start: 1.25em; }
.reading-layout .reply-content > :is(h1, h2, h3, h4, h5, h6) + * { margin-block-start: .4em; }
.reading-layout .reply-content :is(ul, ol) { padding-inline-start: 1.5em; }
.reading-layout .reply-content li + li { margin-block-start: .3em; }
.reading-layout .reply-content li > * + * { margin-block-start: .5em; }
.reading-layout .reply-content strong { font-weight: 650; }
.reading-layout .reply-content a { color: #304f78; text-underline-offset: .17em; }

.reading-layout .reply-content blockquote {
  margin-inline: 0;
  padding-inline-start: .8em;
  border-inline-start: 3px solid #cbd4de;
  color: #49576a;
}

.reading-layout .reply-content blockquote > * + * { margin-block-start: .6em; }
.reading-layout .reply-content hr { border: 0; border-top: 1px solid var(--line); }
.reading-layout .reply-content code {
  padding: .13em .3em;
  border-radius: 5px;
  background: #eff2f7;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .875em;
}

.reading-layout .reply-content pre {
  margin-inline: 0;
  margin-block-end: 0;
  padding: .8em 1em;
  border-radius: 12px;
  background: #eff2f7;
  white-space: pre-wrap;
}

.reading-layout .reply-content pre:first-child { margin-block-start: 0; }
.reading-layout .reply-content pre code { padding: 0; }
.reading-layout .reply-table { overflow-x: auto; }
.reading-layout .reply-table:focus-visible { outline-offset: -2px; }
.reading-layout .reply-content table {
  border-collapse: collapse;
  font-size: .9em;
}

.reading-layout .reply-content :is(th, td) {
  min-width: 7em;
  padding: .5em .75em;
  border: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

.reading-layout .reply-content th { background: #eff2f7; }
.reading-layout .reply-content [data-align="center"] { text-align: center; }
.reading-layout .reply-content [data-align="right"] { text-align: right; }
.reading-layout .message-sources {
  margin-block-start: 1.1em;
  padding-block-start: .6em;
  border-block-start: 1px solid var(--line);
  color: #49576a;
}

@media (min-width: 768px) and (max-width: 1100px) {
  .games-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 920px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 620px) {
  .admin-create { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
  .admin-edit { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
}

@media (min-width: 768px) {
  .app {
    display: grid;
    grid-template-columns: clamp(248px, 21vw, 300px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .app.desktop-history-hidden { grid-template-columns: 0 minmax(0, 1fr); }
  .chat { grid-area: 1 / 2; }
  .history-open .chat { border-radius: 0; transform: none; }

  .chat-header {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 16px;
    padding: 13px 22px;
  }

  .workspace-nav { grid-area: auto; }
  #main-header:has(.layout-switch:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr);
  }
  .chat-header-actions { grid-area: 1 / 3; }
  .app:not(.desktop-history-hidden) :is(#show-history, #reset-chat) { display: none; }

  .history, .history-open .history {
    position: relative;
    grid-area: 1 / 1;
    inset: auto;
    width: auto;
    padding: 15px 18px 19px;
    border-inline-end: 1px solid var(--line);
    visibility: visible;
    transform: none;
    transition: none;
  }

  .desktop-history-hidden .history { padding-inline: 0; border: 0; visibility: hidden; }
  .scrim { display: none; }
  .composer-panel { padding-bottom: 20px; }
}

@media (max-height: 520px) {
  @media (min-width: 768px) {
    .welcome { padding-block: 14px; }
    .prompt-section { margin-top: 14px; }
    .history { gap: 7px; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat, .history, .layout-switch::before { transition: none; }
}
