/* ==========================================================================
   play.kittycat.games — Portal, 5 Spin-Off Games & Chia State-Channel Styles
   Complies with modern-web-guidance (CSS Custom Properties, @starting-style,
   transition-behavior: allow-discrete, overlay, prefers-reduced-motion).
   ========================================================================== */

:root {
  --bg-deep: #0f1423;
  --bg-panel: #1a2238;
  --bg-card: #232d4b;
  --border-gold: #ffd32a;
  --accent-red: #ff3f34;
  --accent-green: #05c46b;
  --accent-cyan: #00d8d6;
  --text-main: #f8f9fa;
  --text-muted: #b2bec3;
  --font-ui: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Courier New', ui-monospace, monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(
    circle at 50% 0%,
    hsl(var(--sky-hue, 202) 55% 22%),
    var(--bg-deep) 75%
  );
  color: var(--text-main);
  font-family: var(--font-ui);
  line-height: 1.4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header & Navigation */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: rgba(15, 20, 35, 0.94);
  border-bottom: 2px solid var(--border-gold);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-badge {
  font-size: 1.65rem;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  color: var(--border-gold);
  text-shadow: 2px 2px 0 #b33939;
}

.portal-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--accent-cyan);
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.retro-select,
.retro-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 0.72rem;
  border-radius: 8px;
  border: 2px solid #485460;
  background: var(--bg-card);
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.retro-btn:hover,
.retro-select:hover {
  border-color: var(--border-gold);
  transform: translateY(-1px);
}

.retro-btn:focus-visible,
.retro-select:focus-visible,
.touch-btn:focus-visible,
.spinoff-tab:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 2px;
}

.retro-btn.accent {
  background: #8c7ae6;
  border-color: #dcdde1;
}

.retro-btn.chia-btn {
  background: #009432;
  border-color: #55efc4;
  color: #ffffff;
}

.retro-btn.catnip-btn {
  background: #10ac84;
  border-color: #a3cb38;
}

.retro-btn.brochure-link {
  background: #192a56;
  border-color: var(--accent-cyan);
}

.retro-btn.primary-cta {
  background: var(--accent-green);
  border-color: #ffffff;
  color: #0b1911;
  font-size: 0.96rem;
  padding: 0.6rem 1.2rem;
}

.retro-btn.danger-cta {
  background: var(--accent-red);
  border-color: var(--border-gold);
  color: #ffffff;
  font-size: 0.92rem;
  padding: 0.6rem 1.05rem;
}

/* Roblox-Style Spin-Off Selector Strip */
.portal-spinoff-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.48rem 1.25rem;
  background: rgba(11, 16, 29, 0.95);
  border-bottom: 2px solid #2f3542;
}

.spinoff-bar-label {
  font-size: 0.76rem;
  color: var(--border-gold);
  letter-spacing: 0.04em;
}

.spinoff-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.spinoff-tab {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.36rem 0.7rem;
  border-radius: 999px;
  border: 2px solid #3c486b;
  background: #182138;
  color: #dfe4ea;
  cursor: pointer;
  transition: all 0.15s ease;
}

.spinoff-tab.active {
  background: var(--tab-accent, var(--border-gold));
  border-color: #ffffff;
  color: #090d16;
  box-shadow: 0 0 12px rgba(255, 211, 42, 0.45);
}

/* Live 1v1 Chia State Channel Bar */
.channel-live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: linear-gradient(90deg, rgba(5, 196, 107, 0.18), rgba(0, 216, 214, 0.16));
  border: 2px solid #05c46b;
  border-radius: 10px;
}

.channel-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
}

.chia-dot {
  color: #05c46b;
  font-size: 1rem;
}

.state-pill {
  background: rgba(0, 216, 214, 0.25);
  border: 1px solid var(--accent-cyan);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.72rem;
}

.channel-vs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player-slot {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  border: 1px solid #57606f;
  background: rgba(15, 20, 35, 0.8);
  color: #dfe4ea;
  cursor: pointer;
}

.player-slot.active-turn {
  border: 2px solid var(--border-gold);
  background: rgba(255, 211, 42, 0.2);
  color: #ffffff;
}

.vs-badge {
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--border-gold);
}

.settle-btn {
  background: var(--border-gold);
  color: #0b0f19;
  border-color: #ffffff;
  font-size: 0.76rem;
  padding: 0.3rem 0.65rem;
}

/* Main Game Layout */
.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1120px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.stage-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* HUD Strip */
.hud-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
  background: rgba(26, 34, 56, 0.95);
  border: 2px solid #3c486b;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
}

@media (max-width: 768px) {
  .hud-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 35, 0.65);
  padding: 0.28rem 0.4rem;
  border-radius: 6px;
}

.hud-stat.danger-stat {
  border: 1px solid rgba(255, 63, 52, 0.7);
  background: rgba(255, 63, 52, 0.14);
}

.hud-label {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.hud-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: #ffffff;
}

.highlight-cats {
  color: var(--border-gold);
  font-size: 1.15rem;
}

.escape-progress {
  width: 100%;
  height: 12px;
  accent-color: hsl(calc(120 - var(--danger-pct, 0) * 1.1) 85% 50%);
}

/* Featured Kitty Alert Banner */
.cat-alert-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.85rem;
  background: linear-gradient(90deg, rgba(255, 165, 2, 0.22), rgba(255, 71, 87, 0.2));
  border-left: 5px solid var(--border-gold);
  border-radius: 8px;
}

.banner-icon {
  font-size: 1.5rem;
}

.banner-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem;
}

.banner-text strong {
  color: var(--border-gold);
  font-size: 0.9rem;
}

.banner-text span {
  font-size: 0.82rem;
  color: #f1f2f6;
}

/* Canvas Viewport */
.canvas-stage-wrapper {
  position: relative;
  background: #090d16;
  border: 3px solid var(--border-gold);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1080 / 560;
  image-rendering: crisp-edges;
}

/* Touch / Arcade Bar */
.arcade-touch-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: rgba(15, 20, 35, 0.95);
  border-top: 2px solid #2f3640;
}

.touch-dpad,
.touch-actions {
  display: flex;
  gap: 0.45rem;
}

.touch-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 2px solid #57606f;
  background: #2f3542;
  color: #ffffff;
  cursor: pointer;
  user-select: none;
}

.touch-btn.jump {
  background: #e1b12c;
  color: #1e272e;
  border-color: #fbc531;
}

.touch-btn.sprint {
  background: #eb2f06;
  border-color: #ff6b81;
}

.touch-btn.catnip {
  background: #009432;
  border-color: #a3cb38;
}

/* Sidebar */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.active-pack-card,
.guide-accordions {
  background: rgba(26, 34, 56, 0.92);
  border: 2px solid #3c486b;
  border-radius: 10px;
  padding: 0.75rem;
}

.active-pack-card h2,
.guide-accordions h2 {
  margin: 0 0 0.35rem 0;
  font-size: 0.98rem;
  color: var(--border-gold);
}

.pack-subtitle {
  margin: 0 0 0.5rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.channel-receipt-box {
  background: rgba(11, 16, 29, 0.85);
  border: 1px solid #2f3542;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.active-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
}

.cat-badge-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.36rem 0.5rem;
  border-radius: 8px;
  background: rgba(15, 20, 35, 0.75);
  border-left: 4px solid var(--cat-color, #ff8c24);
}

.cat-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cat-color, #ff8c24);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.cat-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cat-meta strong {
  font-size: 0.8rem;
  color: #ffffff;
}

.cat-meta span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Native Disclosures (<details> / <summary>) */
details {
  border: 1px solid #3c486b;
  border-radius: 8px;
  background: rgba(15, 20, 35, 0.6);
  margin-bottom: 0.4rem;
  overflow: hidden;
}

summary {
  padding: 0.45rem 0.65rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  color: #f1f2f6;
}

details[open] summary {
  border-bottom: 1px solid #3c486b;
  color: var(--border-gold);
}

.details-body {
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  color: #dfe4ea;
}

.details-body ul {
  margin: 0;
  padding-left: 1.1rem;
}

code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.12);
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  color: var(--border-gold);
}

.bottom-bar {
  text-align: center;
  padding: 0.45rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(15, 20, 35, 0.9);
  border-top: 1px solid #2f3542;
}

.bottom-bar p {
  margin: 0;
}

.footer-link {
  color: var(--border-gold);
}

/* ==========================================================================
   Native <dialog> Top-Layer Animations & Forms
   ========================================================================== */
dialog.retro-dialog {
  border: 3px solid var(--border-gold);
  border-radius: 14px;
  background: var(--bg-panel);
  color: var(--text-main);
  padding: 0;
  max-width: 860px;
  width: min(92vw, 860px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);

  opacity: 0;
  transform: scale(0.92);
  transition-property: opacity, transform, overlay, display;
  transition-duration: 0.25s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.retro-dialog.stage-modal {
  max-width: 560px;
}

dialog.retro-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(3px);
  transition-property: background-color, display, overlay;
  transition-duration: 0.25s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

:is(dialog.retro-dialog[open]):where(:not([data-closing])) {
  opacity: 1;
  transform: scale(1);

  @starting-style {
    opacity: 0;
    transform: scale(0.92);
  }

  &::backdrop {
    background-color: rgba(8, 12, 24, 0.72);

    @starting-style {
      background-color: rgba(0, 0, 0, 0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.retro-dialog,
  dialog.retro-dialog::backdrop {
    transform: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    dialog.retro-dialog[open] {
      transform: none;
    }
  }
}

.dialog-inner {
  padding: 1.25rem 1.5rem;
}

.dialog-inner.centered {
  text-align: center;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid #3c486b;
  padding-bottom: 0.65rem;
}

.dialog-header h2 {
  margin: 0;
  color: var(--border-gold);
  font-size: 1.2rem;
}

.dialog-lead {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Chia Channel Form */
.channel-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-col label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--border-gold);
}

.form-col input {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid #485460;
  background: #0f1423;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.settlement-banner {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(5, 196, 107, 0.18);
  border: 2px solid var(--accent-green);
  font-size: 0.86rem;
}

.cat-dex-grid {
  list-style: none;
  margin: 0.75rem 0 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
}

.dex-card {
  background: rgba(15, 20, 35, 0.85);
  border: 2px solid var(--cat-color, #ff8c24);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dex-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.dex-card-header strong {
  color: var(--border-gold);
  font-size: 0.92rem;
}

.dex-level-pill {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--cat-color, #ff8c24);
  color: #0b0f19;
}

.dex-power-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.dex-desc {
  margin: 0;
  font-size: 0.76rem;
  color: #dfe4ea;
}

.modal-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--border-gold);
  color: #111;
  margin-bottom: 0.4rem;
}

.modal-cat-spotlight {
  margin: 0.85rem 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(15, 20, 35, 0.85);
  border: 2px solid var(--border-gold);
  text-align: left;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.9rem;
}
