/* See docs/mobile-design.md for the Figma frames and Android reference. */
:root { --mobile-surface: #eff2f7; }

.desktop-only { display: none !important; }

.app {
  --mobile-safe-top: env(safe-area-inset-top, 0px);
  --mobile-header-height: 79px;
  --mobile-glass: rgb(255 255 255 / 88%);
}

.chat { background: var(--mobile-surface); }

.chat-header {
  display: flex;
  justify-content: space-between;
  min-height: calc(var(--mobile-header-height) + var(--mobile-safe-top));
  padding: calc(var(--mobile-safe-top) + 12px) 20px 0;
  border: 0;
  background: transparent;
}

.chat-header :is(.header-brand > img, .workspace-nav, #reset-chat) { display: none; }
.chat-header-actions:has(.layout-switch[hidden]) { display: none; }
#main-header { gap: 4px; }
.layout-switch { width: clamp(106px, calc(100vw - 220px), 144px); }
.chat-header .round { background: var(--mobile-glass); }
.chat-header .round:active { background: #e0e6ef; }
#show-history img { filter: brightness(.39); }

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.limit-indicator {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 70px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--pill);
  background: var(--mobile-glass);
  font-size: 16px;
  line-height: 20px;
}

.limit-indicator::before {
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 2px;
  width: 13px;
  border-radius: 100px 0 0 100px / 200px 0 0 200px;
  background: var(--yellow);
  content: "";
}

.mobile-header-actions .icon { width: 24px; height: 24px; }

.games-catalog { padding: 16px 20px 28px; }
.catalog-inner > h1, .games-catalog-heading h1 { font-size: 32px; font-weight: 400; line-height: 36px; letter-spacing: -.03em; }
.category-grid, .games-list { gap: 12px; margin-top: 16px; }
.category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.games-list { grid-template-columns: minmax(0, 1fr); }
.game-tile { min-height: 210px; aspect-ratio: 3 / 2; }
.game-tile-title { font-size: 24px; }
.category-tile { padding: clamp(12px, 4vw, 16px); border-radius: 22px; }
.category-tile .tile-copy { font-size: 16px; }
.game-preview {
  --preview-gutters: 16px;
  inset: auto 0 max(8px, var(--safe-bottom)) 0;
  max-height: calc(100dvh - max(8px, var(--safe-bottom)) - max(12px, var(--mobile-safe-top)));
  margin: 0 auto;
}
.game-preview-cover { height: clamp(92px, 19dvh, 148px); }

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 0 0 7px;
  overflow: hidden;
}

.welcome-inner { display: contents; }

.welcome-intro {
  display: block;
  padding-block-start: max(0px, min(calc(33dvh - var(--mobile-header-height) - var(--mobile-safe-top)), calc(100dvh - 575px)));
  padding-inline: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.welcome-mark { display: none; }

.welcome-copy h1 {
  font-size: 32px;
  font-weight: 400;
  line-height: 36px;
  letter-spacing: -.03em;
}

.welcome-copy p {
  max-width: none;
  margin-top: 18px;
  color: var(--ink);
  font-size: 20px;
  line-height: 28.5px;
  letter-spacing: -.02em;
}

.prompt-section {
  margin: 0;
  padding-top: 14px;
}

.scenario-tile {
  --tile-height: 112px;
  position: relative;
  isolation: isolate;
  display: block;
  width: calc(var(--tile-height) * 1.3);
  height: var(--tile-height);
  margin: 0 auto 20px;
  overflow: hidden;
  border-radius: 24px;
  background: #25375d;
  color: white;
  text-align: left;
}

.scenario-tile img { width: 100%; height: 100%; object-fit: cover; object-position: center 14%; }

.scenario-tile::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(0deg, rgb(13 22 43 / 90%), transparent 60%);
  content: "";
}

.scenario-tile-label, .scenario-tile-arrow { position: absolute; z-index: 1; }
.scenario-tile-label { inset: auto 11px 11px; font-size: 14px; font-weight: 550; line-height: 18px; }

.scenario-tile-arrow {
  inset: 10px 9px auto auto;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--mobile-glass);
  color: var(--ink);
}

.scenario-tile-arrow .icon { width: 16px; height: 16px; }
.scenario-tile:active img { filter: brightness(.9); }

.prompts {
  display: flex;
  gap: 4px;
  margin-inline: 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

.prompt {
  flex: none;
  display: block;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--pill);
  background: var(--mobile-glass);
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
}

.prompt-featured { background: var(--yellow); }
.prompt[data-quick-prompt="tariff"] { padding-inline: 17px; }
.prompt:focus-visible { outline-offset: -3px; }

.composer-panel {
  padding: 0 4px calc(9px + var(--safe-bottom));
  background: var(--mobile-surface);
}

.composer-panel .composer {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px 32px;
  grid-template-rows: minmax(24px, auto) 32px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 94px;
  padding: 14px 12px 12px;
  border: 0;
  border-radius: 32px;
  background: var(--paper);
  box-shadow: none;
}

.composer-panel .composer textarea {
  grid-column: 1 / -1;
  min-height: 24px;
  max-height: min(126px, 22dvh);
  padding: 0 4px;
  font-size: 16px;
  line-height: 24px;
}

.composer-panel textarea::placeholder { color: #8e99af; }

.composer-panel .composer-button {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.composer-attach { grid-area: 2 / 1; }
.composer-mic { grid-area: 2 / 3; }
.composer-panel .send { grid-area: 2 / 4; }
.composer-attach, .composer-mic, .composer-panel .send:disabled { background: #eff3f6; }
.composer-panel .send:disabled { color: #a1acc0; }
.composer-panel .composer-button .icon { width: 19px; height: 19px; }
.composer-panel .send-icon { height: 12px; }
.composer-panel .send-icon::before { width: 8px; height: 8px; }

.disclaimer {
  margin-top: 4px;
  color: #8e99af;
  font-size: 13px;
  line-height: 16px;
}

.chat-transcript .conversation { padding: 12px 20px 16px; }
.chat-transcript .messages { gap: 0; }
#messages { font-size: 20px; line-height: 26px; }
.chat-transcript .user-message {
  max-width: 88%;
  padding: 12px 16px;
  border: 0;
  border-radius: 22px 22px 4px 22px;
  font-size: 16px;
  line-height: 20px;
}

.chat-transcript .assistant-message {
  width: min(100%, 310px);
  padding: 20px 16px 12px 0;
  font-size: 20px;
  line-height: 26px;
}

.chat-transcript .reply-author { display: none; }

.reading-layout #main-header { box-shadow: 0 1px 0 #eff2f7; }
.reading-layout #main-header :is(.round, .limit-indicator) { background: #eff2f7; }
.reading-layout #chat-body .conversation { padding-block: 16px 24px; }
.reading-layout #chat-body .composer { box-shadow: inset 0 0 0 1px #dce2e8; }

.history-open .chat { border-radius: 32px 0 0 32px; }
.scrim { background: rgb(240 243 245 / 70%); }

.history {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  grid-template-rows: 44px auto minmax(0, 1fr) auto auto;
  gap: 0 8px;
  padding: calc(var(--mobile-safe-top) + 23px) 24px calc(12px + var(--safe-bottom));
}

.history-header { grid-area: 1 / 2; }
.history-header .icon { display: none; }
.history-header img { display: block; }
.search-field { grid-area: 1 / 1; }
.search-field input { height: 42px; }
.search-field input::placeholder { color: #77849d; }
.search-field .icon { width: 16px; height: 16px; }

.history-mode {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 60px;
  margin-block: 20px 30px;
  padding-inline: 16px;
  border-radius: 22px;
  background: radial-gradient(ellipse 130% 145% at 100% 110%, #a6fffd 10%, #ffc800 76%);
  font-size: 16px;
  font-weight: 500;
  line-height: 20px;
}

.history-mode img { display: inline-block; vertical-align: top; transform: translateY(-8px); }

.history-mode-switch {
  flex: 0 0 44px;
  height: 24px;
  border-radius: var(--pill);
  background: rgb(40 48 63 / 20%);
}

.history-mode-switch::before {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgb(32 38 50 / 80%);
  content: "";
}

.history-conversations { grid-column: 1 / -1; padding: 0; }
.history-conversations h3 {
  margin: 2px 0 8px;
  color: #77849d;
  font-size: 13px;
  font-weight: 400;
  line-height: 16px;
}

.history-empty { margin-inline: 0; }
.history-entry {
  min-height: 36px;
  padding: 8px 0;
  font-size: 16px;
  line-height: 20px;
}
.history-entry::before { content: none; }

.new-chat {
  grid-area: 4 / 1 / 5 / -1;
  min-height: 56px;
  border: 0;
  border-radius: var(--pill);
  font-size: 16px;
  font-weight: 500;
  text-transform: lowercase;
}
.new-chat .icon { display: none; }

.history-footer {
  grid-area: 5 / 1 / 6 / -1;
  gap: 0;
  padding-top: 8px;
  border: 0;
}
.history-footer .history-profile { display: none; }
.history-footer .account-actions { justify-content: center; gap: 0 14px; }
.history-footer .account-button {
  flex: none;
  min-height: 28px;
  padding: 2px;
  border: 0;
  background: none;
  color: #66748a;
  font-size: 13px;
  font-weight: 400;
}

@media (max-width: 390px) {
  .scenario-tile { --tile-height: 104px; }
}

@media (max-height: 700px) {
  .scenario-tile { --tile-height: clamp(80px, 24vw, 94px); margin-bottom: 10px; }
  .scenario-tile-label { inset: auto 8px 8px; font-size: 13px; line-height: 16px; }
  .scenario-tile-arrow { inset: 7px 7px auto auto; width: 22px; height: 22px; }
}

@media (max-height: 600px) {
  .app { --mobile-header-height: 58px; }
  .chat-header { padding-top: var(--mobile-safe-top); }
  .history-mode { margin-block: 12px; }
  .welcome-copy h1 { font-size: 28px; line-height: 34px; }
  .welcome-copy p { margin-top: 10px; font-size: 18px; line-height: 24px; }
}

@media (max-height: 430px) {
  .welcome {
    display: flex;
    overflow-y: auto;
  }

  .welcome-intro { flex: none; overflow: visible; }
  .prompt-section { margin-top: auto; }
}
