:root {
  --bg: #111417;
  --panel: rgba(230, 238, 232, 0.08);
  --panel-strong: rgba(230, 238, 232, 0.13);
  --line: rgba(230, 238, 232, 0.14);
  --text: #edf7ef;
  --muted: #b8c7c1;
  --accent: #8fd2c4;
  --accent-strong: #dce7b7;
  --success: #91d1a0;
  --danger: #ff8a80;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(143, 210, 196, 0.16), transparent 30%),
    radial-gradient(circle at bottom, rgba(142, 166, 113, 0.13), transparent 34%),
    linear-gradient(180deg, #141918 0%, #0f1212 100%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.55), transparent 85%);
  pointer-events: none;
}

.app-shell {
  width: min(100%, 540px);
  margin: 0 auto;
  min-height: 100svh;
  padding: 20px 16px 32px;
}

.app-shell.focused {
  width: min(100%, 760px);
  padding: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 18px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hidden-topbar {
  display: none;
}

.hidden {
  display: none !important;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-family: Georgia, "Times New Roman", serif;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent-strong);
}

.app-root {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stage-root {
  width: 100%;
}

.panel {
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  min-height: 34svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 35% -10% -20%;
  background: radial-gradient(circle, rgba(215, 164, 91, 0.2), transparent 52%);
}

.hero-copy,
.hero-actions,
.button-row,
.stats-grid,
.guess-grid,
.timeline,
.center-copy,
.waiting-copy {
  position: relative;
  z-index: 1;
}

.hero-copy h2,
.center-copy h2,
.waiting-copy h2 {
  margin: 10px 0 8px;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  line-height: 1;
  font-family: Georgia, "Times New Roman", serif;
}

.hero-copy p,
.muted,
.meta-label,
.center-copy p,
.waiting-copy p {
  color: var(--muted);
}

.stage-screen {
  min-height: calc(100svh - 52px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.focus-screen {
  min-height: 100svh;
}

.focus-panel {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 28px 22px;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.focus-title,
.center-copy,
.waiting-copy {
  text-align: center;
}

.focus-title {
  font-size: 1rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button,
input {
  border: none;
  border-radius: 999px;
  font: inherit;
}

button {
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.receiver-mandala .mandala-card:hover {
  transform: none;
}

.receiver-mandala .slot-1:hover {
  transform: translateX(-50%);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 12px 16px;
}

.primary-button {
  background: var(--accent);
  color: #0d1c19;
  font-weight: 700;
}

.secondary-button {
  background: rgba(248, 241, 226, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

input[type="text"],
input[type="file"] {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 14px 16px;
  width: 100%;
  border: 1px solid transparent;
}

input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

input[type="file"] {
  display: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
}

.role-gate-screen {
  min-height: 100svh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 14px;
  padding: 22px 0;
}

.role-gate-card {
  aspect-ratio: 0.78;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  border-radius: 18px;
  background: rgba(230, 238, 232, 0.07);
  border: 1px solid var(--line);
  color: var(--text);
}

.role-gate-card svg {
  width: min(28vw, 118px);
  height: min(28vw, 118px);
  stroke: var(--accent-strong);
  stroke-width: 3.6;
  fill: none;
}

.role-gate-card span {
  font-size: 1rem;
  color: var(--muted);
}

.zen-flow-screen {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.zen-flow-screen::after {
  content: none;
}

.zen-form {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.zen-main-action {
  width: 100%;
  min-height: 52px;
}

.quiet-link {
  justify-self: center;
  align-self: center;
}

.room-list {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.zen-room-list {
  max-height: 36svh;
  overflow: auto;
}

.room-option {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--text);
}

.room-option span {
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.room-option strong {
  font-size: 1.05rem;
}

.room-option small {
  color: var(--muted);
}

.role-grid,
.guess-grid,
.stats-grid,
.split {
  display: grid;
  gap: 12px;
}

.role-grid,
.guess-grid,
.stats-grid,
.split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.receiver-grid .guess-button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.guess-button,
.role-button {
  min-height: 108px;
  padding: 12px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
}

.receiver-mandala {
  position: relative;
  width: min(88vw, calc(100svh - 220px), 520px);
  aspect-ratio: 1;
  margin: 0 auto;
  transition: opacity 160ms ease;
}

.receiver-mandala.is-waiting {
  opacity: 0.72;
}

.mandala-card {
  position: absolute;
  width: clamp(82px, 24vw, 128px);
  height: clamp(82px, 24vw, 128px);
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.mandala-card svg {
  width: 56%;
  height: 56%;
}

.slot-1 {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.slot-2 {
  top: 31%;
  right: 0;
}

.slot-3 {
  bottom: 0;
  right: 13%;
}

.slot-4 {
  bottom: 0;
  left: 13%;
}

.slot-5 {
  top: 31%;
  left: 0;
}

.receiver-grid .guess-button {
  min-height: 124px;
}

.guess-button svg,
.role-button svg,
.symbol-display svg {
  width: 54px;
  height: 54px;
  stroke: var(--accent-strong);
  stroke-width: 4;
  fill: none;
}

.symbol-display {
  min-height: 240px;
  display: grid;
  place-items: center;
  border-radius: 30px;
  background: radial-gradient(circle, rgba(215, 164, 91, 0.17), transparent 60%);
  border: 1px solid rgba(255,255,255,0.08);
  animation: pulseSymbol 1.8s ease-in-out infinite;
}

.focus-symbol {
  min-height: 42svh;
}

.focus-symbol svg {
  width: min(52vw, 220px);
  height: min(52vw, 220px);
}

@keyframes pulseSymbol {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.04); opacity: 1; }
}

.metric {
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 60px 1fr 56px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ec6c7, var(--accent-strong));
  animation: growBar 900ms ease forwards;
}

@keyframes growBar {
  to { width: var(--bar-width); }
}

.sparkline {
  width: 100%;
  height: 90px;
}

.sparkline polyline {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reward-image {
  width: 100%;
  border-radius: 24px;
  border: 1px solid var(--line);
  display: block;
}

.notice,
.info,
.error {
  padding: 14px 16px;
  border-radius: 18px;
}

.notice {
  border: 1px solid rgba(145, 209, 160, 0.3);
  color: var(--success);
  background: rgba(145, 209, 160, 0.08);
}

.info {
  border: 1px solid rgba(126, 198, 199, 0.3);
  color: #bde8e7;
  background: rgba(126, 198, 199, 0.08);
}

.error {
  border: 1px solid rgba(255, 138, 128, 0.3);
  color: var(--danger);
  background: rgba(255, 138, 128, 0.08);
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

@media (max-width: 460px) {
  .role-grid,
  .stats-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .role-gate-screen {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .focus-panel {
    padding: 24px 16px;
  }

  .receiver-mandala {
    width: min(90vw, calc(100svh - 170px), 390px);
  }
}
