:root {
  --portal-ink: #1e2430;
  --portal-muted: #586173;
  --portal-paper: #fff9ef;
  --portal-surface: #ffffff;
  --portal-line: #d9e1ec;
  --portal-blue: #2364a6;
  --portal-blue-dark: #173f70;
  --portal-green: #3f8d55;
  --portal-coral: #ec624f;
  --portal-yellow: #f3b73f;
  --portal-teal: #168a93;
  --portal-shadow: 0 18px 45px rgba(23, 47, 79, 0.14);
  --portal-radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.portal-unified {
  min-width: 0;
  margin: 0;
  color: var(--portal-ink);
  background: var(--portal-paper);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
}

.portal-brand-header,
.portal-brand-footer {
  color: var(--portal-ink);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.portal-brand-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 70px;
  padding: 0.7rem clamp(1rem, 3vw, 2.5rem);
  background: rgba(255, 249, 239, 0.95);
  border-bottom: 1px solid rgba(30, 36, 48, 0.08);
  backdrop-filter: blur(14px);
}

.portal-brand-link,
.portal-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.portal-brand-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  object-fit: contain;
  padding: 0.18rem;
  background: #fff;
  border-radius: var(--portal-radius);
}

.portal-brand-title,
.portal-brand-subtitle {
  display: block;
}

.portal-brand-title {
  font-size: 0.98rem;
  font-weight: 950;
  line-height: 1.15;
}

.portal-brand-subtitle {
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.portal-brand-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.portal-brand-nav a {
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--portal-radius);
  color: var(--portal-ink);
  font-weight: 900;
  text-decoration: none;
}

.portal-brand-nav a:hover,
.portal-brand-nav a:focus-visible {
  color: #fff;
  background: var(--portal-blue);
  outline: none;
}

.portal-brand-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  color: #fff;
  background: #101925;
}

.portal-footer-brand {
  color: #fff;
}

.portal-footer-brand .portal-brand-logo {
  width: 64px;
  height: 64px;
}

.portal-footer-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 800;
  text-align: center;
}

.portal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.portal-footer-actions a {
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  color: var(--portal-ink);
  background: var(--portal-yellow);
  border-radius: var(--portal-radius);
  font-weight: 950;
  text-decoration: none;
}

.portal-footer-characters {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 0.2rem;
  min-width: 90px;
}

.portal-footer-characters img {
  width: 48px;
  height: 70px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.32));
}

.portal-footer-characters img:last-child {
  transform: scaleX(-1);
}

body.portal-unified img {
  max-width: 100%;
}

body.portal-unified button,
body.portal-unified .btn,
body.portal-unified a.btn,
body.portal-unified .primary,
body.portal-unified .secondary {
  border-radius: var(--portal-radius);
  letter-spacing: 0;
}

body.portal-unified .btn-primary,
body.portal-unified .button.primary,
body.portal-unified button.primary,
body.portal-unified a.primary {
  color: var(--portal-ink) !important;
  background: var(--portal-yellow) !important;
}

body.portal-unified .btn-secondary,
body.portal-unified .button.secondary,
body.portal-unified button.secondary,
body.portal-unified a.secondary {
  color: #fff !important;
  background: var(--portal-blue) !important;
}

body.portal-unified .card,
body.portal-unified .screen,
body.portal-unified .game-panel,
body.portal-unified .scene-panel {
  border-radius: var(--portal-radius);
}

body.portal-unified .app,
body.portal-unified main.app,
body.portal-unified .page,
body.portal-unified .app-shell,
body.portal-unified #app {
  width: min(1180px, 92vw);
  min-width: 0;
  margin-inline: auto;
}

body.portal-unified > .app,
body.portal-unified > main.app,
body.portal-unified > .page,
body.portal-unified > .app-shell,
body.portal-unified > #app {
  flex: 1 0 auto;
  margin-block: clamp(1rem, 3vw, 2rem);
}

body.portal-unified .portal-responsive-scroll {
  overflow-x: auto;
}

body.portal-unified.portal-phaser-game {
  height: auto;
  min-height: 100vh;
  overflow: auto;
  touch-action: auto;
}

body.portal-unified.portal-phaser-game .shell {
  min-height: auto;
  padding-block: clamp(1rem, 3vw, 1.5rem);
}

body.portal-unified.portal-phaser-game .game-frame {
  max-height: calc(100vh - 230px);
}

@media (max-width: 760px) {
  .portal-brand-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-brand-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .portal-brand-nav a {
    flex: 0 0 auto;
  }

  .portal-brand-footer {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .portal-footer-brand,
  .portal-footer-actions {
    justify-content: center;
  }

  .portal-footer-copy {
    order: 3;
  }
}

@media (pointer: coarse) {
  body.portal-unified.portal-phaser-game .portal-brand-header,
  body.portal-unified.portal-phaser-game .portal-brand-footer {
    display: none;
  }

  body.portal-unified.portal-phaser-game {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--app-height, 100svh);
    overflow: hidden;
    touch-action: none;
  }
}

@media (max-width: 520px) {
  .portal-brand-title {
    font-size: 0.94rem;
  }

  .portal-brand-subtitle {
    font-size: 0.74rem;
  }

  .portal-footer-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
