/* ===== Shared Theme Foundation ===== */

:root {
  --theme-bg-top: #1b2138;
  --theme-bg-bottom: #05060a;
  --theme-surface: rgba(17, 19, 27, 0.94);
  --theme-surface-soft: rgba(23, 25, 38, 0.88);
  --theme-surface-glow: rgba(255, 255, 255, 0.03);
  --theme-border: rgba(255, 255, 255, 0.08);
  --theme-text: #f7f8fc;
  --theme-text-muted: #b7bfd8;
  --theme-orange: #ff7a18;
  --theme-orange-deep: #e76607;
  --theme-green: #4cd964;
  --theme-green-deep: #24b33f;
  --theme-yellow: #ffd447;
  --theme-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --theme-radius: 18px;
  --theme-pill: 999px;
}

body.page-shell {
  min-height: 100vh;
  margin: 0;
  color: var(--theme-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(76, 217, 100, 0.12), transparent 22%),
    radial-gradient(circle at top right, rgba(255, 122, 24, 0.16), transparent 26%),
    linear-gradient(180deg, var(--theme-bg-top) 0%, var(--theme-bg-bottom) 58%, #020308 100%);
  -webkit-font-smoothing: antialiased;
}

.page-shell__wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 18px 40px;
  box-sizing: border-box;
}

.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  margin-bottom: 22px;
}

.site-header--compact {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.site-header__logo img {
  display: block;
  width: min(240px, 58vw);
  height: auto;
}

.site-header__logo--small img {
  width: 72px;
}

.site-header__tagline {
  margin: 0;
  max-width: 42rem;
  color: var(--theme-text-muted);
  font-size: 1rem;
}

.site-header__user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.site-header__greeting {
  font-size: 0.95rem;
  font-weight: 600;
}

.site-header__logout {
  color: var(--theme-text-muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.site-header__logout:hover {
  color: var(--theme-orange);
}

.page-main {
  display: block;
}

.landing-grid {
  display: grid;
  gap: 18px;
}

.surface-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--theme-surface-glow) 0%, transparent 100%), var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius);
  box-shadow: var(--theme-shadow);
  padding: 22px;
}

.surface-card--soft {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 100%), var(--theme-surface-soft);
}

.surface-card__title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 4vw, 2.55rem);
  line-height: 1.02;
}

.surface-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--theme-pill);
  margin-bottom: 14px;
  background: rgba(76, 217, 100, 0.13);
  border: 1px solid rgba(76, 217, 100, 0.22);
  color: var(--theme-green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.surface-card__body,
.surface-card p,
.dashboard-copy,
.dashboard-note,
.field-help,
.quick-join__help,
.muted-copy {
  color: var(--theme-text-muted);
  line-height: 1.55;
}

.feature-grid,
.dashboard-grid,
.info-grid {
  display: grid;
  gap: 14px;
}

.feature-tile,
.info-tile,
.dashboard-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 15px;
}

.feature-tile strong,
.info-tile strong,
.dashboard-card__title {
  display: block;
  margin-bottom: 6px;
  color: var(--theme-text);
}

.story-bubbles {
  margin: 22px 0 18px;
}

.story-bubbles__header {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.story-bubbles__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 11px;
  border-radius: var(--theme-pill);
  background: rgba(255, 122, 24, 0.14);
  border: 1px solid rgba(255, 122, 24, 0.24);
  color: var(--theme-orange);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-bubbles__eyebrow::before {
  content: "";
  width: 12px;
  height: 12px;
  background: url('../img/newflame.svg') center / contain no-repeat;
  filter: drop-shadow(0 0 4px rgba(255, 122, 24, 0.38));
}

.story-bubbles__intro {
  margin: 0;
  color: var(--theme-text-muted);
  line-height: 1.45;
}

.story-bubble-container {
  position: relative;
  width: 100%;
  height: 410px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(76, 217, 100, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(8, 10, 16, 0.94) 0%, rgba(18, 21, 31, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.story-bubble {
  --bubble-tilt: -1.5deg;
  position: absolute;
  max-width: 480px;
  min-width: 260px;
  padding: 16px 20px;
  background: #fffdf8;
  border-radius: 16px;
  border: 3px solid var(--theme-orange);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  color: #191919;
  opacity: 0;
  transform: scale(0.9) rotate(var(--bubble-tilt));
  transition: opacity 0.8s ease, transform 0.8s ease, left 0.8s ease, top 0.8s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: grab;
  touch-action: none;
}

.story-bubble:nth-child(odd) {
  --bubble-tilt: -2deg;
}

.story-bubble:nth-child(even) {
  --bubble-tilt: 1.6deg;
}

.story-bubble::before {
  content: "";
  position: absolute;
  bottom: -22px;
  left: 40px;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 22px solid var(--theme-orange);
}

.story-bubble::after {
  content: "";
  position: absolute;
  bottom: -18px;
  left: 44px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 18px solid #fffdf8;
}

.story-bubble__title {
  margin-bottom: 6px;
  color: var(--theme-orange);
  font-size: 0.88rem;
  font-weight: 800;
}

.story-bubble__text {
  line-height: 1.45;
  color: #1b1b1b;
}

.story-bubble--fade-1 {
  filter: brightness(0.86);
}

.story-bubble--fade-2 {
  filter: brightness(0.66);
}

.story-bubble--fade-3 {
  filter: brightness(0.42);
}

.story-bubble--dragging {
  cursor: grabbing;
  z-index: 20;
}

.story-bubble,
.story-bubble * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.quick-join {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.quick-join__label {
  display: block;
  margin-bottom: 8px;
  color: var(--theme-yellow);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quick-join__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

body.page-shell input,
body.page-shell textarea,
body.page-shell select {
  width: 100%;
  margin: 0;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 8, 14, 0.82);
  color: var(--theme-text);
  box-sizing: border-box;
}

body.page-shell input::placeholder,
body.page-shell textarea::placeholder {
  color: #8690ae;
}

body.page-shell input:focus,
body.page-shell textarea:focus,
body.page-shell select:focus {
  outline: none;
  border-color: rgba(255, 122, 24, 0.85);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.16);
}

.field-stack {
  display: grid;
  gap: 12px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--theme-text);
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

body.page-shell .btn,
body.page-shell button.btn,
body.page-shell a.btn {
  display: inline-flex;
  width: auto;
  margin: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: var(--theme-pill);
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.08s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out, border-color 0.12s ease-out;
}

body.page-shell .btn:hover {
  transform: translateY(-1px);
}

body.page-shell .btn:active {
  transform: translateY(1px) scale(0.99);
}

body.page-shell .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: rgba(17, 19, 27, 0.88);
  border-color: var(--theme-orange);
  color: var(--theme-text);
  box-shadow: 0 12px 28px rgba(255, 122, 24, 0.16);
}

.btn--primary:hover {
  background: rgba(26, 28, 39, 0.98);
}

.btn--secondary {
  background: rgba(17, 19, 27, 0.88);
  border-color: var(--theme-green);
  color: var(--theme-text);
  box-shadow: 0 12px 28px rgba(76, 217, 100, 0.14);
}

.btn--secondary:hover {
  background: rgba(26, 28, 39, 0.98);
}

.btn--accent {
  background: var(--theme-orange);
  border-color: var(--theme-orange);
  color: #0b0d12;
  box-shadow: 0 14px 26px rgba(255, 122, 24, 0.26);
}

.btn--accent:hover {
  background: var(--theme-orange-deep);
  border-color: var(--theme-orange-deep);
}

.btn--success {
  background: var(--theme-green);
  border-color: var(--theme-green);
  color: #08110a;
  box-shadow: 0 14px 26px rgba(76, 217, 100, 0.22);
}

.btn--success:hover {
  background: var(--theme-green-deep);
  border-color: var(--theme-green-deep);
}

.btn--ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--theme-text-muted);
}

.btn--ghost:hover {
  color: var(--theme-text);
  border-color: var(--theme-yellow);
}

.password-toggle.btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  position: relative;
}

.password-toggle__icon {
  width: 18px;
  height: 18px;
  display: block;
}

.password-toggle__slash {
  display: none;
}

.password-toggle[aria-pressed="true"] .password-toggle__slash {
  display: block;
}

.return-note,
.panel-note,
.status-card,
.story-gate-note {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 212, 71, 0.2);
  background: rgba(255, 212, 71, 0.08);
  color: #ffe7a1;
}

.return-note a,
.story-gate-note a,
.site-footer a,
.auth-switch a,
.link-inline {
  color: var(--theme-yellow);
}

.return-note a:hover,
.story-gate-note a:hover,
.site-footer a:hover,
.auth-switch a:hover,
.link-inline:hover {
  color: var(--theme-orange);
}

.form-msg {
  min-height: 1.2em;
  margin-top: 10px;
  color: #ffe7a1;
}

.auth-block + .auth-block {
  margin-top: 18px;
}

.auth-switch {
  margin-top: 16px;
  color: var(--theme-text-muted);
  font-size: 0.95rem;
}

.text-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--theme-yellow);
  cursor: pointer;
  font: inherit;
}

.text-button:hover {
  color: var(--theme-orange);
}

.dashboard-hero {
  margin-bottom: 18px;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 18px;
}

.dashboard-primary-action {
  margin: 16px 0 18px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--theme-pill);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mini-badge--orange {
  background: rgba(255, 122, 24, 0.12);
  border: 1px solid rgba(255, 122, 24, 0.25);
  color: #ffb277;
}

.mini-badge--green {
  background: rgba(76, 217, 100, 0.12);
  border: 1px solid rgba(76, 217, 100, 0.25);
  color: #8df29d;
}

.dashboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dashboard-list__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dashboard-list__meta {
  color: var(--theme-text-muted);
  font-size: 0.9rem;
}

.site-footer {
  margin-top: 28px;
  padding: 8px 0 10px;
  color: var(--theme-text-muted);
  font-size: 0.88rem;
  text-align: center;
}

.site-footer__nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.debug-box {
  display: none;
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(4, 6, 10, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cad1e8;
  white-space: pre-wrap;
  font-size: 12px;
}

@media (max-width: 559px) {
  .site-header--compact {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .site-header__user {
    align-items: center;
  }

  .quick-join__row,
  .dashboard-actions,
  .site-footer__nav {
    flex-direction: column;
  }

  .quick-join__row > *,
  .dashboard-primary-action .btn,
  .dashboard-primary-action button,
  .dashboard-primary-action a.btn,
  .dashboard-actions .btn,
  .dashboard-actions button,
  .dashboard-actions a.btn {
    width: 100%;
  }

  .password-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .story-bubble-container {
    height: 360px;
  }

  .story-bubble {
    min-width: 220px;
    width: min(88%, 380px);
    padding: 14px 16px;
  }
}

@media (min-width: 700px) {
  .feature-grid,
  .info-grid,
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .story-bubble-container {
    height: 430px;
  }
}

@media (min-width: 900px) {
  .page-shell__wrap {
    padding: 28px 28px 46px;
  }

  .landing-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.92fr);
    align-items: start;
  }

  .landing-grid__wide {
    grid-column: 1 / span 2;
  }
}

/* ===== Global Layout ===== */

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #f7f7f7;
  font-size: 18px;
  line-height: 1.4;
}

/* Mobile scaling */
@viewport {
  width: device-width;
  zoom: 1.0;
}

/* ===== Headings ===== */

h1 {
  font-size: 28px;
  margin: 0 0 20px 0;
  text-align: center;
}

h2 {
  font-size: 22px;
  margin: 24px 0 8px 0;
}

/* ===== Links ===== */

a {
  color: #0078d4;
  text-decoration: none;
  font-size: 18px;
}

a.button {
  display: block;
  width: 100%;
  padding: 16px;
  margin: 12px 0;
  background: #0078d4;
  color: white;
  text-align: center;
  border-radius: 6px;
}

a.button:active {
  background: #005fa3;
}

/* ===== Inputs ===== */

input, textarea, select {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

/* ===== Buttons ===== */

button {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  margin: 14px 0;
  border: none;
  border-radius: 6px;
  background: #063183;
  color: white;
  cursor: pointer;
}

button:active {
  background: #041f5d;
}

.guess-buttons {
  display: flex;
  gap: 10px;
}

.guess-buttons button {
  width: 100%;
}

/* ===== Messages ===== */

.msg, #msg, #create-info, #join-info {
  margin-top: 12px;
  font-size: 18px;
  text-align: center;
  color: #444;
}

/* ===== QR Code ===== */

#qr {
  display: none;
  margin: 20px auto;
  width: min(80vw, 260px);
  height: min(80vw, 260px);
}

/* ===== Containers ===== */

.container {
  padding: 16px;
}
