:root {
  --bg: #07111f;
  --bg-deep: #030814;
  --surface: rgba(10, 23, 41, 0.84);
  --surface-strong: #0f2035;
  --surface-soft: rgba(17, 35, 59, 0.72);
  --line: rgba(184, 219, 255, 0.12);
  --line-strong: rgba(184, 219, 255, 0.22);
  --text: #eef6ff;
  --muted: #97aeca;
  --accent: #ff7a45;
  --accent-2: #4ce0c9;
  --accent-3: #ffce52;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --container: 1180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(76, 224, 201, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 122, 69, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
canvas {
  font: inherit;
}

.arcade-list {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.selector-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-soft);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.selector-card:hover,
.selector-card:focus-visible,
.control-button:hover,
.control-button:focus-visible,
.merge-button:hover,
.merge-button:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.selector-card strong {
  font-family: "Sora", sans-serif;
  display: block;
  margin-bottom: 8px;
}

.selector-card p,
.selector-card small {
  color: var(--muted);
}

.selector-card.active {
  border-color: rgba(255, 122, 69, 0.38);
  background:
    radial-gradient(circle at top right, rgba(255, 122, 69, 0.18), transparent 38%),
    rgba(17, 35, 59, 0.92);
}

.selector-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selector-tag,
.stage-pill,
.hud-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.control-button.primary,
.merge-button.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #ff9154);
  box-shadow: 0 16px 42px rgba(255, 122, 69, 0.25);
}

.control-button,
.merge-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.arcade-stage-card {
  display: grid;
  gap: 18px;
}

.stage-head {
  display: grid;
  gap: 14px;
}

.arcade-stage {
  min-height: 620px;
}

.game-shell {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-soft);
}

.stage-hud {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-soft);
}

.hud-row,
.control-row,
.merge-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hud-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-soft);
}

.hud-strong,
.game-card-title,
.arcade-stage h3,
.selector-card strong {
  font-family: "Sora", sans-serif;
}

.hud-note,
.game-note,
.stage-pill,
.compact {
  color: var(--muted);
}

.hud-strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1;
}

.game-canvas {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  background: #071423;
  touch-action: none;
}

.control-button,
.merge-button {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 16px;
  cursor: pointer;
}

.merge-shell {
  display: grid;
  gap: 16px;
}

.merge-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.merge-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 4vw, 1.3rem);
}

.merge-tile[data-value="2"] { background: #21344b; }
.merge-tile[data-value="4"] { background: #28415d; }
.merge-tile[data-value="8"] { background: #35618f; }
.merge-tile[data-value="16"] { background: #4a7cb7; }
.merge-tile[data-value="32"] { background: #6b7aff; }
.merge-tile[data-value="64"] { background: #8d61ff; }
.merge-tile[data-value="128"] { background: #bf59f8; }
.merge-tile[data-value="256"] { background: #ff7a45; }
.merge-tile[data-value="512"] { background: #ff925a; }
.merge-tile[data-value="1024"] { background: #ffb24d; }
.merge-tile[data-value="2048"] { background: #ffd74b; color: #1a1a1a; }

.merge-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-soft);
}

.mobile-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mobile-pad .merge-button:nth-child(1) {
  grid-column: 2;
}

.mobile-pad .merge-button:nth-child(2) {
  grid-column: 1;
}

.mobile-pad .merge-button:nth-child(3) {
  grid-column: 2;
}

.mobile-pad .merge-button:nth-child(4) {
  grid-column: 3;
}

@media (min-width: 720px) {
  .arcade-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-shell {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }
}

/* ── Cozy theme (home + arcade) ── */

.theme-home,
.theme-arcade,
.theme-documents {
  --cozy-bg: #d9d0c6;
  --cozy-surface: #e8e0d6;
  --cozy-surface-soft: #ddd4c9;
  --cozy-surface-hover: #d4cbc0;
  --cozy-border: #c8bbb0;
  --cozy-text: #4a433c;
  --cozy-muted: #8a7f74;
  --cozy-accent: #d88662;
  --cozy-accent-hover: #c97552;
  --cozy-accent-soft: #edd5c6;
  --cozy-shadow: 0 10px 36px rgba(74, 67, 60, 0.1);
  --cozy-shadow-soft: 0 3px 14px rgba(74, 67, 60, 0.07);
  --cozy-radius: 20px;
  --cozy-radius-sm: 14px;
  --cozy-stage: #5c534b;

  color: var(--cozy-text);
  background: var(--cozy-bg);
}

.theme-home .visually-hidden,
.theme-arcade .visually-hidden,
.theme-documents .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Documents page (documents.html) ── */

.documents-page {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.documents-header {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.documents-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.documents-kicker {
  margin: 0 0 5px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cozy-muted);
}

.documents-title-row h1 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.documents-status,
.documents-panel-head span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(200, 187, 176, 0.5);
  border-radius: 999px;
  color: var(--cozy-muted);
  background: rgba(255, 252, 247, 0.5);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.documents-main {
  display: grid;
  gap: 14px;
}

.documents-sidebar,
.documents-inspector {
  display: grid;
  gap: 12px;
  align-content: start;
}

.documents-drop,
.documents-panel,
.documents-workspace {
  border: 1px solid rgba(200, 187, 176, 0.5);
  border-radius: var(--cozy-radius-sm);
  background: rgba(255, 252, 247, 0.56);
  box-shadow: var(--cozy-shadow-soft);
}

.documents-drop {
  display: grid;
  gap: 9px;
  place-items: center;
  min-height: 150px;
  padding: 18px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.documents-drop:hover,
.documents-drop:focus-within,
.documents-drop.drag-over {
  border-color: rgba(216, 134, 98, 0.6);
  background: rgba(255, 250, 244, 0.88);
  transform: translateY(-1px);
}

.documents-drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--cozy-accent-hover);
  background: var(--cozy-accent-soft);
}

.documents-drop-icon svg {
  width: 22px;
  height: 22px;
}

.documents-drop-title {
  font-family: "Sora", sans-serif;
  font-weight: 700;
}

.documents-drop-note {
  font-size: 0.78rem;
  color: var(--cozy-muted);
}

.documents-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.documents-panel h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.documents-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.documents-targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.documents-target,
.documents-primary,
.documents-toolbar button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--cozy-text);
  background: rgba(255, 252, 247, 0.62);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.documents-target {
  display: grid;
  gap: 1px;
  padding: 9px 10px;
  text-align: left;
}

.documents-target span {
  font-family: "Sora", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.documents-target small {
  color: var(--cozy-muted);
  font-size: 0.7rem;
}

.documents-target:hover,
.documents-target:focus-visible,
.documents-toolbar button:hover,
.documents-toolbar button:focus-visible {
  background: rgba(255, 250, 244, 0.92);
  border-color: rgba(200, 187, 176, 0.75);
  outline: none;
}

.documents-target.active {
  border-color: rgba(216, 134, 98, 0.52);
  background: var(--cozy-accent-soft);
}

.documents-primary {
  width: 100%;
  color: #fffaf5;
  background: var(--cozy-accent);
  font-weight: 800;
}

.documents-primary:hover,
.documents-primary:focus-visible {
  background: var(--cozy-accent-hover);
  transform: translateY(-1px);
  outline: none;
}

.documents-primary:disabled {
  opacity: 0.68;
  cursor: wait;
  transform: none;
}

.documents-facts {
  display: grid;
  gap: 9px;
  margin: 0;
}

.documents-file-name {
  display: grid;
  gap: 7px;
}

.documents-file-name span {
  color: var(--cozy-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.documents-file-name input {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid rgba(200, 187, 176, 0.5);
  border-radius: 11px;
  color: var(--cozy-text);
  background: rgba(255, 252, 247, 0.62);
  outline: none;
}

.documents-file-name input:focus {
  border-color: rgba(216, 134, 98, 0.62);
  background: rgba(255, 250, 244, 0.92);
}

.documents-facts div {
  display: grid;
  gap: 2px;
}

.documents-facts dt {
  color: var(--cozy-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.documents-facts dd {
  min-width: 0;
  margin: 0;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.documents-workspace {
  display: grid;
  min-width: 0;
  overflow: hidden;
}

.documents-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(200, 187, 176, 0.5);
  background: rgba(232, 224, 214, 0.7);
}

.documents-toolbar button {
  min-width: 42px;
  padding: 0 11px;
  font-size: 0.82rem;
  font-weight: 700;
}

.documents-toolbar-spacer {
  flex: 1 1 12px;
}

.documents-editor {
  display: grid;
  gap: 18px;
  min-height: 520px;
  padding: clamp(22px, 4vw, 44px);
  color: #28231f;
  background: #fffaf5;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.documents-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.documents-field span {
  color: rgba(138, 127, 116, 0.9);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.documents-field input,
.documents-field textarea {
  width: 100%;
  border: 0;
  border-radius: 0;
  color: #28231f;
  background: transparent;
  outline: none;
  resize: none;
}

.documents-field input {
  font-family: "Sora", sans-serif;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.documents-field textarea {
  min-height: 360px;
  font: inherit;
  line-height: 1.72;
}

.documents-field input::placeholder,
.documents-field textarea::placeholder {
  color: rgba(138, 127, 116, 0.58);
}

.documents-field:focus-within span {
  color: var(--cozy-accent-hover);
}

.documents-preview-panel {
  min-height: 260px;
}

.documents-pdf-preview {
  width: 100%;
  min-height: 360px;
  border: 1px solid rgba(200, 187, 176, 0.5);
  border-radius: 12px;
  background: #fffaf5;
}

.documents-preview-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 220px;
  padding: 24px;
  border: 1px dashed rgba(138, 127, 116, 0.42);
  border-radius: 12px;
  color: var(--cozy-muted);
  text-align: center;
}

.documents-preview-empty strong {
  color: var(--cozy-text);
}

.documents-log {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.documents-log li {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 252, 247, 0.52);
  color: var(--cozy-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (min-width: 860px) {
  .documents-main {
    grid-template-columns: 240px minmax(0, 1fr) 270px;
    align-items: start;
  }

  .documents-sidebar,
  .documents-inspector {
    position: sticky;
    top: 16px;
  }
}

@media (max-width: 640px) {
  .documents-title-row {
    align-items: start;
    flex-direction: column;
  }

  .documents-editor {
    min-height: 420px;
  }
}

@media print {
  body.theme-documents {
    background: #fff;
  }

  .documents-header,
  .documents-sidebar,
  .documents-inspector,
  .documents-toolbar {
    display: none;
  }

  .documents-page,
  .documents-main,
  .documents-workspace,
  .documents-editor {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }
}

/* ── Home hub (index.html) ── */

.hub-page {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.hub-header {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.hub-brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
}

.hub-brand {
  font-family: "Sora", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--cozy-text);
}

.hub-tagline {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--cozy-muted);
}

.hub-greeting {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--cozy-muted);
}

.hub-main {
  display: grid;
  gap: 24px;
}

.hub-section {
  display: grid;
  gap: 10px;
}

.hub-section-title {
  margin: 0;
  padding: 0 4px;
  font-family: "Sora", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--cozy-text);
}

.hub-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 2px;
}

.hub-card {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--cozy-radius-sm);
  background: rgba(255, 252, 247, 0.56);
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.hub-card--live:hover,
.hub-card--live:focus-visible {
  background: rgba(255, 250, 244, 0.86);
  border-color: rgba(200, 187, 176, 0.72);
  box-shadow: 0 10px 22px rgba(74, 67, 60, 0.08);
  outline: none;
}

.hub-card--soon {
  opacity: 0.72;
  cursor: default;
}

.hub-card-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--cozy-muted);
  opacity: 0.72;
  flex-shrink: 0;
}

.hub-icon-svg {
  width: 16px;
  height: 16px;
}

.hub-card-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  align-content: center;
}

.hub-card-title {
  display: block;
  min-width: 0;
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--cozy-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-card-note {
  display: block;
  min-width: 0;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--cozy-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: "Manrope", sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.hub-badge--live {
  color: var(--cozy-accent-hover);
  background: var(--cozy-accent-soft);
}

.hub-badge--soon {
  color: var(--cozy-muted);
  background: rgba(255, 252, 247, 0.5);
  border: 1px solid rgba(200, 187, 176, 0.45);
}

@media (min-width: 640px) {
  .hub-card-note {
    white-space: normal;
  }
}

/* ── Arcade page (games.html) ── */
.arcade-page {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.arcade-header {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.arcade-back {
  font-family: "Sora", sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cozy-muted);
  transition: color 0.2s ease;
}

.arcade-back:hover,
.arcade-back:focus-visible {
  color: var(--cozy-accent);
}

.arcade-greeting {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--cozy-muted);
}

.arcade-main {
  display: grid;
  gap: 20px;
}

.arcade-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 4px 0;
}

.arcade-sidebar-head {
  display: grid;
  padding: 0 4px;
  flex-shrink: 0;
}

.arcade-sidebar-head h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--cozy-text);
}

.theme-arcade .arcade-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 2px 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  overflow: visible;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(138, 127, 116, 0.3) transparent;
}

.arcade-list-empty {
  margin: 0;
  padding: 24px 12px;
  font-size: 0.82rem;
  line-height: 1.55;
  text-align: center;
  color: var(--cozy-muted);
}

.theme-arcade .selector-card,
.theme-arcade .selector-card--user {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.56);
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
  cursor: pointer;
  overflow: visible;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.theme-arcade .selector-card:hover,
.theme-arcade .selector-card:focus-visible,
.theme-arcade .selector-card--user:hover,
.theme-arcade .selector-card--user:focus-within {
  transform: none;
  filter: none;
  background: rgba(255, 250, 244, 0.86);
  border-color: rgba(200, 187, 176, 0.72);
  box-shadow: 0 10px 22px rgba(74, 67, 60, 0.08);
  outline: none;
}

.theme-arcade .selector-card.active,
.theme-arcade .selector-card--user.active {
  background: rgba(255, 249, 242, 0.96);
  border-color: rgba(216, 134, 98, 0.42);
  box-shadow: 0 14px 28px rgba(74, 67, 60, 0.1);
}

.theme-arcade .selector-card.active::before,
.theme-arcade .selector-card--user.active::before {
  display: none;
}

.selector-card-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--cozy-muted);
  opacity: 0.72;
  flex-shrink: 0;
}

.theme-arcade .selector-card.active .selector-card-icon,
.theme-arcade .selector-card--user.active .selector-card-icon {
  color: var(--cozy-text);
  opacity: 0.7;
}

.selector-icon-svg {
  width: 16px;
  height: 16px;
}

.selector-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
  align-content: center;
}

.theme-arcade .selector-card-title,
.theme-arcade .selector-card strong {
  display: block;
  min-width: 0;
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  color: var(--cozy-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-arcade .selector-card.active .selector-card-title,
.theme-arcade .selector-card--user.active .selector-card-title,
.theme-arcade .selector-card.active strong,
.theme-arcade .selector-card--user.active strong {
  color: var(--cozy-text);
}

.selector-card-type {
  display: block;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--cozy-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.arcade-play {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius);
  background: var(--cozy-surface);
  box-shadow: var(--cozy-shadow);
}

.arcade-play-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 2px;
}

.arcade-play-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.arcade-fullscreen-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--cozy-border);
  border-radius: 999px;
  font-family: "Sora", sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--cozy-text);
  background: var(--cozy-surface-soft);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.arcade-fullscreen-btn:hover,
.arcade-fullscreen-btn:focus-visible {
  background: var(--cozy-accent-soft);
  border-color: var(--cozy-accent);
  color: var(--cozy-accent-hover);
}

.arcade-play-meta h1 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--cozy-text);
  letter-spacing: -0.02em;
}

.arcade-best {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--cozy-accent-hover);
  background: var(--cozy-accent-soft);
}

.theme-arcade .arcade-stage {
  min-height: 0;
}

.theme-arcade .game-shell {
  display: grid;
  gap: 14px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.theme-arcade .stage-hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.theme-arcade .hud-box {
  padding: 12px 14px;
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius-sm);
  background: var(--cozy-surface-soft);
}

.theme-arcade .hud-note {
  color: var(--cozy-muted);
  font-size: 0.76rem;
}

.theme-arcade .hud-strong {
  font-size: 1.35rem;
  color: var(--cozy-text);
}

.theme-arcade .game-note {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--cozy-muted);
}

.theme-arcade .game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid #b8aa9c;
  border-radius: var(--cozy-radius-sm);
  background: var(--cozy-stage);
  box-shadow: inset 0 2px 10px rgba(58, 52, 46, 0.18);
}

.theme-arcade .game-canvas-portrait {
  --portrait-ui-offset: 14rem;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 420 / 560;
  max-height: min(calc(100dvh - var(--portrait-ui-offset)), 560px);
  margin: 0;
  touch-action: none;
}

.theme-arcade .portrait-game-shell {
  --portrait-frame-w: min(94vw, 420px);
  gap: 10px;
}

.theme-arcade .portrait-game-shell .stage-hud .controls {
  grid-column: 1 / -1;
  justify-content: center;
}

.theme-arcade .portrait-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

@media (min-width: 600px) and (max-width: 899px) {
  .theme-arcade .portrait-game-shell {
    width: min(100%, var(--portrait-frame-w));
    margin-inline: auto;
  }
}

.theme-arcade .game-canvas-dino {
  background: #f8efe4;
  border-color: #c8bbb0;
  aspect-ratio: 760 / 260;
}

.dino-runner-host {
  width: 100%;
}

.dino-runner-host .game-canvas-dino {
  display: block;
  width: 100%;
  height: auto;
  background: #f8efe4;
  border: 1px solid #c8bbb0;
  border-radius: var(--cozy-radius-sm);
  cursor: pointer;
}

.theme-arcade .dino-game-shell {
  gap: 16px;
}

.theme-arcade .dino-game-shell .game-viewport,
.theme-arcade .dino-game-shell .dino-runner-host {
  width: 100%;
  min-width: 0;
}

.theme-arcade .game-viewport {
  display: flex;
  justify-content: center;
}

.theme-arcade .control-button,
.theme-arcade .merge-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.theme-arcade .control-button.primary,
.theme-arcade .merge-button.primary {
  color: #faf4ee;
  background: var(--cozy-accent);
  border: none;
  box-shadow: 0 4px 16px rgba(216, 134, 98, 0.28);
}

.theme-arcade .control-button,
.theme-arcade .merge-button:not(.primary) {
  color: var(--cozy-text);
  border: 1px solid var(--cozy-border);
  background: var(--cozy-surface-soft);
}

.theme-arcade .control-button:hover,
.theme-arcade .control-button:focus-visible,
.theme-arcade .merge-button:hover,
.theme-arcade .merge-button:focus-visible {
  transform: translateY(-1px);
  filter: none;
  background: var(--cozy-surface-hover);
  border-color: #bfb2a5;
}

.theme-arcade .control-button.primary:hover,
.theme-arcade .control-button.primary:focus-visible,
.theme-arcade .merge-button.primary:hover,
.theme-arcade .merge-button.primary:focus-visible {
  background: var(--cozy-accent-hover);
}

.theme-arcade .hud-chip {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--cozy-border);
  border-radius: 12px;
  background: var(--cozy-surface-soft);
  color: var(--cozy-text);
  font-size: 0.86rem;
  font-weight: 600;
}

.theme-arcade .merge-shell {
  gap: 14px;
}

.theme-arcade .merge-panel {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.theme-arcade .merge-panel .eyebrow {
  display: none;
}

.theme-arcade .merge-board {
  padding: 10px;
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius-sm);
  background: var(--cozy-surface-soft);
  gap: 8px;
}

.theme-arcade .merge-tile {
  border-radius: 10px;
  font-size: 0.95rem;
}

.theme-arcade .merge-tile[data-value="0"] {
  background: rgba(200, 187, 176, 0.5);
}

.theme-arcade .merge-tile[data-value="2"] { background: #d9cfc4; color: var(--cozy-text); }
.theme-arcade .merge-tile[data-value="4"] { background: #cfc0b2; color: var(--cozy-text); }
.theme-arcade .merge-tile[data-value="8"] { background: #c4a896; color: var(--cozy-text); }
.theme-arcade .merge-tile[data-value="16"] { background: #d88662; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="32"] { background: #cc7858; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="64"] { background: #c06a4e; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="128"] { background: #b45c44; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="256"] { background: #a84e3a; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="512"] { background: #9c4230; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="1024"] { background: #903626; color: #faf4ee; }
.theme-arcade .merge-tile[data-value="2048"] { background: #842a1c; color: #faf4ee; }

@media (min-width: 600px) and (max-width: 899px) {
  .arcade-sidebar {
    max-height: none;
    overflow: visible;
  }

  .theme-arcade .arcade-list {
    overflow-y: auto;
    flex: 0 0 auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 127, 116, 0.55) transparent;
  }

  .theme-arcade .arcade-list::-webkit-scrollbar {
    width: 8px;
  }

  .theme-arcade .arcade-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(138, 127, 116, 0.45);
  }
}

@media (max-width: 420px) {
  .theme-arcade .selector-card,
  .theme-arcade .selector-card--user {
    padding: 8px 10px;
    gap: 8px;
  }

  .selector-card-icon {
    width: 18px;
    height: 18px;
  }

  .selector-icon-svg {
    width: 15px;
    height: 15px;
  }

  .theme-arcade .selector-card-title,
  .theme-arcade .selector-card strong {
    font-size: 0.84rem;
  }
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active)  {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px;
  border: none;
  border-radius: 0;
  background: var(--cozy-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-play-meta  {
  flex-shrink: 0;
  width: min(100%, 480px);
  margin: 0 auto;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-stage  {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .game-canvas-dino  {
  max-height: min(78vh, 820px);
  width: min(100%, calc(78vh * 760 / 260));
  margin: 0 auto;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell  {
  --portrait-frame-w: min(440px, 92vw, calc((100dvh - 10.5rem) * 420 / 560));
  --portrait-ui-offset: 10.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: var(--portrait-frame-w);
  max-width: 92vw;
  margin: 0 auto;
  padding: 12px;
  background: var(--cozy-surface);
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius);
  box-shadow: var(--cozy-shadow);
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .stage-hud  {
  width: 100%;
  flex-shrink: 0;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .portrait-viewport  {
  flex: none;
  width: 100%;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .game-canvas-portrait  {
  width: 100%;
  max-height: min(calc(100dvh - var(--portrait-ui-offset)), calc(var(--portrait-frame-w) * 560 / 420));
  border: none;
  border-radius: calc(var(--cozy-radius-sm) - 2px);
  box-shadow: inset 0 2px 10px rgba(58, 52, 46, 0.2);
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell  {
  min-height: calc(100vh - 122px);
  align-items: center;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell .stage-hud  {
  max-width: 260px;
}

.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .merge-board  {
  max-width: 420px;
  margin: 0 auto;
}

body.arcade-is-fullscreen {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

html.arcade-is-fullscreen {
  overflow: hidden;
  height: 100%;
}

body.arcade-is-fullscreen .arcade-header,
body.arcade-is-fullscreen .arcade-sidebar {
  display: none;
}

body.arcade-is-fullscreen .arcade-page {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  padding: 0;
}

body.arcade-is-fullscreen .arcade-main {
  display: block;
}

/* Pseudo-fullscreen layer — must work outside media queries (iOS Safari) */
.arcade-play.arcade-fs-active {
  --arcade-fs-bar: max(44px, calc(env(safe-area-inset-top, 0px) + 36px));
  --arcade-fs-pad-inline: max(0px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --arcade-fs-pad-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--arcade-vh, 100dvh);
  min-height: -webkit-fill-available;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #1e1b18;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

.arcade-play.arcade-fs-active .arcade-play-meta {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  flex-shrink: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(30, 27, 24, 0.94) 0%, rgba(30, 27, 24, 0.55) 72%, transparent 100%);
  pointer-events: none;
}

.arcade-play.arcade-fs-active .arcade-play-meta h1,
.arcade-play.arcade-fs-active .arcade-best {
  display: none;
}

.arcade-play.arcade-fs-active .arcade-play-actions {
  margin-left: auto;
  pointer-events: auto;
}

.arcade-play.arcade-fs-active .arcade-fullscreen-btn {
  min-height: 36px;
  padding: 0 14px;
  border-color: rgba(250, 244, 238, 0.22);
  color: #faf4ee;
  background: rgba(58, 52, 46, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.arcade-play.arcade-fs-active .arcade-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  height: 100%;
  padding: var(--arcade-fs-bar) var(--arcade-fs-pad-inline) var(--arcade-fs-pad-bottom);
  box-sizing: border-box;
}

body.arcade-fs-portrait-game .arcade-play.arcade-fs-active .portrait-game-shell {
  --portrait-ui-offset: var(--arcade-fs-bar);
  --portrait-frame-w: min(100vw, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 420 / 560));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: var(--portrait-frame-w);
  max-width: 100%;
  height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(var(--portrait-frame-w) * 560 / 420));
  margin: 0 auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.arcade-fs-portrait-game .arcade-play.arcade-fs-active .portrait-game-shell .stage-hud {
  flex-shrink: 0;
  width: 100%;
  gap: 8px;
}

body.arcade-fs-portrait-game .arcade-play.arcade-fs-active .portrait-game-shell .portrait-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
}

body.arcade-fs-portrait-game .arcade-play.arcade-fs-active .portrait-game-shell .game-canvas-portrait {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 420 / 560;
  border: none;
  border-radius: 10px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.28);
}

body.arcade-fs-portrait-game.arcade-orient-landscape .arcade-play.arcade-fs-active .portrait-game-shell {
  --portrait-frame-w: min(calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 420 / 560), calc(100vw - 2 * var(--arcade-fs-pad-inline)));
  flex-direction: row;
  align-items: stretch;
  width: auto;
  max-width: 100%;
  height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(var(--portrait-frame-w) * 560 / 420));
}

body.arcade-fs-portrait-game.arcade-orient-landscape .arcade-play.arcade-fs-active .portrait-game-shell .stage-hud {
  width: min(38vw, 168px);
  align-content: start;
}

body.arcade-fs-landscape-game .arcade-play.arcade-fs-active .dino-game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
}

body.arcade-fs-landscape-game .arcade-play.arcade-fs-active .dino-game-shell .stage-hud {
  position: absolute;
  top: var(--arcade-fs-bar);
  left: max(10px, env(safe-area-inset-left, 0px));
  z-index: 20;
  width: min(42vw, 168px);
  max-width: 168px;
  margin: 0;
  pointer-events: auto;
  opacity: 0.94;
}

body.arcade-fs-landscape-game .arcade-play.arcade-fs-active .dino-game-shell .game-viewport {
  width: min(100%, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 16 / 9));
  height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(100vw * 9 / 16));
  max-width: calc(100vw - 2 * var(--arcade-fs-pad-inline));
  max-height: calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom));
  aspect-ratio: 16 / 9;
  background: #141210;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

body.arcade-fs-landscape-game .arcade-play.arcade-fs-active .dino-runner-host {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
}

body.arcade-fs-landscape-game .arcade-play.arcade-fs-active .game-canvas-dino {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  border: none;
  border-radius: 0;
  object-fit: contain;
}

body.arcade-fs-landscape-game.arcade-orient-landscape .arcade-play.arcade-fs-active .dino-game-shell .game-viewport {
  width: min(100vw, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 16 / 9));
  height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(100vw * 9 / 16));
}

body.arcade-fs-landscape-game.arcade-orient-landscape .arcade-play.arcade-fs-active .dino-game-shell .stage-hud {
  top: max(8px, env(safe-area-inset-top, 0px));
  left: max(10px, env(safe-area-inset-left, 0px));
}

body.arcade-is-fullscreen.arcade-fs-landscape-game.arcade-orient-portrait .arcade-rotate-hint {
  display: flex;
}

body.arcade-is-fullscreen.arcade-fs-landscape-game.arcade-orient-landscape .arcade-rotate-hint {
  display: none;
}

/* Mobile fullscreen — edge-to-edge, YouTube-style orientation */
.arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active)  {
  --arcade-fs-bar: max(44px, calc(env(safe-area-inset-top, 0px) + 36px));
  --arcade-fs-pad-inline: max(0px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --arcade-fs-pad-bottom: max(0px, env(safe-area-inset-bottom, 0px));
}

@media (hover: none) and (pointer: coarse), (max-width: 599px) {
  .arcade-play.arcade-fs-active {
    position: fixed;
    inset: 0;
    z-index: 10000;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: #1e1b18;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-play-meta {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
    background: linear-gradient(180deg, rgba(30, 27, 24, 0.94) 0%, rgba(30, 27, 24, 0.55) 72%, transparent 100%);
    pointer-events: none;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-play-meta h1 {
    display: none;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-best {
    display: none;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-play-actions {
    margin-left: auto;
    pointer-events: auto;
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-fullscreen-btn {
    min-height: 36px;
    padding: 0 14px;
    border-color: rgba(250, 244, 238, 0.22);
    color: #faf4ee;
    background: rgba(58, 52, 46, 0.72);
    backdrop-filter: blur(8px);
  }

  .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .arcade-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    height: 100%;
    padding: var(--arcade-fs-bar) var(--arcade-fs-pad-inline) var(--arcade-fs-pad-bottom);
    box-sizing: border-box;
  }

  /* Portrait games — fill phone height in portrait, pillarbox in landscape */
  body.arcade-fs-portrait-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell {
    --portrait-ui-offset: var(--arcade-fs-bar);
    --portrait-frame-w: min(100vw, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 420 / 560));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: var(--portrait-frame-w);
    max-width: 100%;
    height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(var(--portrait-frame-w) * 560 / 420));
    margin: 0 auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.arcade-fs-portrait-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .stage-hud {
    flex-shrink: 0;
    width: 100%;
    gap: 8px;
  }

  body.arcade-fs-portrait-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .portrait-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
  }

  body.arcade-fs-portrait-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .game-canvas-portrait {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 420 / 560;
    border: none;
    border-radius: 10px;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.28);
  }

  body.arcade-fs-portrait-game.arcade-orient-landscape .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell {
    --portrait-frame-w: min(calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 420 / 560), calc(100vw - 2 * var(--arcade-fs-pad-inline)));
    flex-direction: row;
    align-items: stretch;
    width: auto;
    max-width: 100%;
    height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(var(--portrait-frame-w) * 560 / 420));
  }

  body.arcade-fs-portrait-game.arcade-orient-landscape .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .portrait-game-shell .stage-hud {
    width: min(38vw, 168px);
    align-content: start;
  }

  /* Landscape games — 16:9 viewport, maximize on rotation */
  body.arcade-fs-landscape-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  body.arcade-fs-landscape-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell .stage-hud {
    position: absolute;
    top: var(--arcade-fs-bar);
    left: max(10px, env(safe-area-inset-left, 0px));
    z-index: 20;
    width: min(42vw, 168px);
    max-width: 168px;
    margin: 0;
    pointer-events: auto;
    opacity: 0.94;
  }

  body.arcade-fs-landscape-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell .game-viewport {
    width: min(100%, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 16 / 9));
    height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(100vw * 9 / 16));
    max-width: calc(100vw - 2 * var(--arcade-fs-pad-inline));
    max-height: calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom));
    aspect-ratio: 16 / 9;
    background: #141210;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    min-width: 0;
  }

  body.arcade-fs-landscape-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-runner-host {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
  }

  body.arcade-fs-landscape-game .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .game-canvas-dino {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    border: none;
    border-radius: 0;
    object-fit: contain;
  }

  body.arcade-fs-landscape-game.arcade-orient-landscape .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell .game-viewport {
    width: min(100vw, calc((100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)) * 16 / 9));
    height: min(calc(100dvh - var(--arcade-fs-bar) - var(--arcade-fs-pad-bottom)), calc(100vw * 9 / 16));
  }

  body.arcade-fs-landscape-game.arcade-orient-landscape .arcade-play:is(:fullscreen, :-webkit-full-screen, .arcade-fs-active) .dino-game-shell .stage-hud {
    top: max(8px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
  }

  .arcade-rotate-hint {
    display: none;
    position: absolute;
    inset: auto 16px max(16px, env(safe-area-inset-bottom, 0px)) 16px;
    z-index: 25;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #faf4ee;
    background: rgba(58, 52, 46, 0.82);
    border: 1px solid rgba(250, 244, 238, 0.16);
    backdrop-filter: blur(10px);
    pointer-events: none;
    text-align: center;
    animation: arcade-rotate-hint-pulse 2.4s ease-in-out infinite;
  }

  body.arcade-is-fullscreen.arcade-fs-landscape-game.arcade-orient-portrait .arcade-rotate-hint {
    display: flex;
  }

  body.arcade-is-fullscreen.arcade-fs-landscape-game.arcade-orient-landscape .arcade-rotate-hint {
    display: none;
  }

  .arcade-rotate-hint-icon {
    display: inline-flex;
    font-size: 1.1rem;
    line-height: 1;
    transform: rotate(90deg);
  }

  @keyframes arcade-rotate-hint-pulse {
    0%, 100% { opacity: 0.72; }
    50% { opacity: 1; }
  }
}

@media (min-width: 720px) and (max-width: 899px) {
  .theme-arcade .portrait-game-shell {
    grid-template-columns: 1fr;
    width: min(100%, var(--portrait-frame-w));
    margin-inline: auto;
  }
}

@media (min-width: 421px) and (max-width: 899px) {
  .theme-arcade .portrait-game-shell {
    --portrait-frame-w: min(400px, 90vw);
  }

  .theme-arcade .portrait-game-shell .game-canvas-portrait {
    --portrait-ui-offset: 12rem;
  }
}

@media (min-width: 900px) {
  .arcade-page {
    width: min(100%, 1280px);
    padding: 28px 24px 48px;
  }

  .arcade-header {
    margin-bottom: 18px;
  }

  .arcade-main {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    align-items: start;
    gap: 22px;
  }

  .arcade-sidebar {
    position: sticky;
    top: 20px;
    align-self: start;
    height: var(--arcade-sidebar-h, calc(100dvh - 6rem));
    max-height: var(--arcade-sidebar-h, calc(100dvh - 6rem));
    overflow: hidden;
  }

  .theme-arcade .arcade-list {
    gap: 1px;
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: none;
    padding-right: 4px;
    padding-bottom: 32px;
  }

  .theme-arcade .arcade-list::-webkit-scrollbar {
    width: 8px;
  }

  .theme-arcade .arcade-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(138, 127, 116, 0.45);
  }

  .theme-arcade .game-shell {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
  }

  .theme-arcade .portrait-game-shell {
    --portrait-frame-w: 420px;
    align-items: center;
  }

  .theme-arcade .portrait-game-shell .portrait-viewport {
    min-height: min(560px, calc(100dvh - 10rem));
  }

  .theme-arcade .portrait-game-shell .game-canvas-portrait {
    --portrait-ui-offset: 9.5rem;
    width: 420px;
    max-width: 100%;
    max-height: min(560px, calc(100dvh - var(--portrait-ui-offset)));
  }

  .theme-arcade .dino-game-shell {
    grid-template-columns: minmax(160px, 185px) minmax(560px, 1fr);
    align-items: center;
  }

  .theme-arcade .dino-game-shell .stage-hud {
    gap: 8px;
  }

  .theme-arcade .stage-hud {
    grid-template-columns: 1fr;
  }

  .theme-arcade .merge-shell {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    align-items: start;
  }

  .theme-arcade .mobile-pad {
    display: none;
  }

  .theme-arcade .merge-hint::after {
    content: " On desktop, arrow keys work too.";
  }
}

@media (min-width: 720px) and (max-width: 899px) {
  .theme-arcade .game-shell {
    grid-template-columns: 1fr;
  }
}

.selector-section {
  margin: 0;
  padding: 14px 12px 3px;
}

.selector-section:first-child {
  padding-top: 4px;
}

.selector-section-label {
  margin: 0;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cozy-muted);
  opacity: 0.8;
}

.selector-section--mine {
  padding-top: 22px;
  padding-bottom: 6px;
}

.selector-section--builtin {
  padding-top: 18px;
  padding-bottom: 7px;
}

.theme-arcade .selector-card--builtin {
  min-height: 58px;
  margin-bottom: 5px;
  padding: 11px 13px;
  border: 1px solid rgba(191, 178, 165, 0.34);
  border-radius: 13px;
  background: rgba(255, 252, 247, 0.76);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 5px 14px rgba(74, 67, 60, 0.035);
}

.theme-arcade .selector-card--builtin.active {
  background: rgba(255, 250, 244, 0.98);
  border-color: rgba(216, 134, 98, 0.46);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.52) inset,
    0 9px 20px rgba(74, 67, 60, 0.07);
}

.theme-arcade .selector-card--builtin:hover,
.theme-arcade .selector-card--builtin:focus-visible {
  background: rgba(255, 250, 244, 0.94);
}

.theme-arcade .selector-card--user {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 6px;
  align-items: stretch;
  padding: 0;
  min-height: 118px;
  margin-bottom: 6px;
  border: 1px solid rgba(191, 178, 165, 0.42);
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.9);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 10px 22px rgba(74, 67, 60, 0.055);
}

.selector-card-main {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 13px 13px 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  appearance: none;
  transition: background 0.18s ease;
}

.selector-card-main:hover,
.selector-card-main:focus-visible {
  transform: none;
  filter: none;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.selector-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
  padding: 2px 13px 14px 43px;
  box-sizing: border-box;
  align-items: stretch;
  border-top: 0;
}

.selector-action-btn {
  min-width: 0;
  min-height: 31px;
  padding: 6px 7px;
  border: 1px solid rgba(200, 187, 176, 0.55);
  border-radius: 10px;
  background: rgba(255, 250, 244, 0.94);
  color: var(--cozy-text);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  cursor: pointer;
  opacity: 1;
  appearance: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.selector-action-btn:hover,
.selector-action-btn:focus-visible {
  background: rgba(255, 248, 241, 0.98);
  border-color: rgba(216, 134, 98, 0.32);
  color: var(--cozy-text);
  transform: translateY(-1px);
  outline: none;
}

.selector-action-btn.danger {
  color: #8d5f50;
}

.selector-action-btn.danger:hover,
.selector-action-btn.danger:focus-visible {
  background: rgba(154, 90, 74, 0.12);
  color: #9a5a4a;
}

.theme-arcade .selector-card--user.active .selector-card-main {
  background: rgba(255, 255, 255, 0.24);
}

.theme-arcade .selector-card--user.active .selector-card-actions {
  border-top-color: rgba(74, 67, 60, 0.08);
}

.theme-arcade .selector-card--create {
  min-height: 62px;
  padding: 12px 13px;
  background: rgba(238, 221, 208, 0.95);
  border-color: rgba(216, 134, 98, 0.22);
  border-radius: 14px;
  align-items: center;
}

.theme-arcade .selector-card--create .selector-card-icon {
  color: var(--cozy-accent-hover);
}

.theme-arcade .selector-card--create .selector-card-body {
  gap: 5px;
}

.theme-arcade .selector-card--create .selector-card-type {
  line-height: 1.35;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .selector-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .selector-action-btn:last-child {
    grid-column: auto;
  }
}

.shared-game-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius-sm);
  background: rgba(216, 134, 98, 0.08);
}

.shared-game-banner p {
  margin: 0;
  flex: 1 1 220px;
  font-size: 0.86rem;
  color: var(--cozy-text);
}

.creator-wizard {
  display: grid;
  gap: 16px;
  padding: 8px 4px 12px;
}

.creator-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.creator-step {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--cozy-surface-soft);
  color: var(--cozy-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.creator-step.active {
  background: var(--cozy-accent-soft);
  color: var(--cozy-accent-hover);
}

.creator-panel h2 {
  margin: 0 0 12px;
  font-family: "Sora", sans-serif;
  font-size: 1.2rem;
  color: var(--cozy-text);
}

.creator-form,
.creator-template-grid,
.creator-question-list {
  display: grid;
  gap: 12px;
}

.creator-template-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.creator-template-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--cozy-border);
  border-radius: var(--cozy-radius-sm);
  background: var(--cozy-surface-soft);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.creator-template-card.active {
  border-color: var(--cozy-accent);
  background: var(--cozy-accent-soft);
}

.creator-template-card strong,
.creator-template-card p {
  margin: 0;
}

.creator-template-card p {
  font-size: 0.82rem;
  color: var(--cozy-muted);
  line-height: 1.45;
}

.creator-field {
  display: grid;
  gap: 6px;
}

.creator-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cozy-muted);
}

.creator-field input,
.creator-field textarea,
.creator-field select,
.creator-option-input,
.creator-question-input,
.share-bar-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cozy-border);
  border-radius: 12px;
  background: var(--cozy-surface);
  color: var(--cozy-text);
  box-shadow: inset 0 1px 2px rgba(74, 67, 60, 0.04);
}

.creator-field textarea,
.creator-question-input {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

.creator-question {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--cozy-border);
  border-radius: 16px;
  background: var(--cozy-surface);
  box-shadow: var(--cozy-shadow-soft);
}

.creator-question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.creator-question-head strong {
  color: var(--cozy-text);
  font-size: 0.92rem;
}

.creator-options {
  display: grid;
  gap: 8px;
}

.creator-option-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--cozy-border);
  border-radius: 12px;
  background: var(--cozy-surface-soft);
}

.creator-option-row input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--cozy-accent);
}

.creator-option-input {
  min-width: 0;
}

.creator-preview-frame {
  min-height: 320px;
  border: 1px solid var(--cozy-border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--cozy-surface-soft);
}

.creator-preview-empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--cozy-muted);
}

.creator-errors {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(178, 77, 58, 0.1);
  color: #8f3d2d;
}

.creator-errors p {
  margin: 0;
  font-size: 0.82rem;
}

.creator-summary {
  margin: 0;
  color: var(--cozy-muted);
  line-height: 1.5;
}

.creator-nav,
.share-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.share-bar {
  display: grid;
  gap: 10px;
}

.creator-primary-btn,
.creator-secondary-btn {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.creator-primary-btn {
  border: 0;
  background: var(--cozy-accent);
  color: #fff;
}

.creator-secondary-btn,
.creator-link-btn {
  border: 1px solid var(--cozy-border);
  background: var(--cozy-surface);
  color: var(--cozy-text);
}

.creator-link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cozy-accent-hover);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.share-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 12px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15, 32, 53, 0.94);
  color: #eef6ff;
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.share-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.share-toast[data-type="error"] {
  background: rgba(143, 61, 45, 0.95);
}

@media (min-width: 600px) and (max-width: 899px) {
  .arcade-main {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    align-items: start;
  }

  .arcade-sidebar {
    position: sticky;
    top: 16px;
    height: var(--arcade-sidebar-h, calc(100dvh - 6rem));
    max-height: var(--arcade-sidebar-h, calc(100dvh - 6rem));
    overflow: hidden;
  }

  .theme-arcade .arcade-list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: none;
    padding-bottom: 32px;
  }
}
