:root {
  color-scheme: light;
  --bg: #f7f3ef;
  --surface: #ffffff;
  --surface-warm: #fff8f1;
  --line: #eadfd4;
  --text: #251d18;
  --muted: #756b63;
  --orange: #ff6a00;
  --orange-dark: #c94600;
  --green: #16845b;
  --red: #cc2f2f;
  --blue: #2563eb;
  --shadow: 0 8px 22px rgba(109, 67, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 106, 0, 0.08), transparent 220px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(12px, calc((100vw - 480px) / 2 + 12px));
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(234, 223, 212, 0.86);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-avatar {
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(240, 75, 0, 0.28);
  border: 2px solid #fff;
}

.brand-text {
  min-width: 0;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
  white-space: nowrap;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

main {
  width: min(480px, calc(100% - 20px));
  margin: 10px auto 0;
}

.campaign-card,
.hero-card,
.answer-card,
.total-card,
.guide-card,
.identity-card,
.tool-panel,
.search-card,
.room-card,
.modal-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.campaign-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
}

.campaign-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.campaign-head h1 {
  margin: 8px 0 0;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0;
}

.hero-card {
  padding: 18px;
  border-radius: 18px;
}

.hero-topline {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 800;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.16);
}

.hero-card h1 {
  margin: 10px 0 8px;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.hero-meta div,
.identity-card,
.stat-box {
  border-radius: 14px;
  background: var(--surface-warm);
  border: 1px solid #ffe1c6;
}

.hero-meta div {
  min-width: 0;
  padding: 10px;
}

.hero-meta span,
.identity-card span,
label span,
.section-head span,
.room-meta span,
.member-row span,
.modal-copy {
  color: var(--muted);
  font-size: 12px;
}

.hero-meta strong {
  display: block;
  margin-top: 4px;
  color: var(--orange-dark);
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.answer-card {
  display: grid;
  gap: 10px;
  margin: 10px 0;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8e8, #fff3d9);
  border: 1px solid #ffc979;
  box-shadow: 0 12px 28px rgba(255, 137, 23, 0.13);
}

.answer-history {
  min-height: 36px;
  border: 1px solid #ffca84;
  border-radius: 10px;
  color: var(--orange-dark);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 850;
}

.answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 10px;
  border-bottom: 1px dashed #f2c890;
}

.answer-row span,
.answer-card small,
.answer-note span {
  color: var(--muted);
  font-size: 12px;
}

.answer-row strong {
  color: #ff4b00;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.answer-row-strong strong {
  font-size: 22px;
  letter-spacing: 0;
}

.answer-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid #ffb77d;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.answer-card small {
  display: block;
}

.answer-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #ffc979;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff8e8, #fff3d9);
}

.answer-strip span,
.campaign-foot span,
.compact-stats span {
  color: var(--muted);
  font-size: 12px;
}

.answer-strip strong {
  display: block;
  margin-top: 4px;
  color: #ff4b00;
  font-size: 22px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.answer-strip .answer-history {
  min-width: 74px;
}

.compact-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.compact-stats div {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid #f0e6dd;
  border-radius: 12px;
  background: #fbf8f5;
}

.compact-stats strong {
  display: block;
  margin-top: 4px;
  color: var(--orange-dark);
  font-size: 16px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.campaign-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding-top: 2px;
}

.campaign-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-foot strong {
  color: var(--text);
}

.total-card {
  margin: 10px 0;
  padding: 10px;
  border-radius: 12px;
  text-align: center;
  color: var(--orange-dark);
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.total-card strong {
  color: #ff4b00;
}

.guide-card {
  display: grid;
  gap: 10px;
  margin: 10px 0;
  padding: 12px;
  border-radius: 14px;
  box-shadow: none;
}

.guide-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.guide-head > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-rules {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.activity-entry {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px dashed #ffb0b0;
  border-radius: 10px;
  color: #c43131;
  background: #fff6f6;
  font-size: 13px;
}

.identity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 12px;
  box-shadow: none;
}

.identity-card strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.identity-card small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tabs {
  position: sticky;
  top: 59px;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: #fff;
  background: linear-gradient(145deg, #ff8a1f, #f04b00);
  box-shadow: 0 8px 18px rgba(240, 75, 0, 0.24);
}

.tab-badge {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: #ff6a00;
  font-size: 10px;
  line-height: 1.4;
  font-weight: 900;
}

.tab.active .tab-badge {
  color: #f04b00;
  background: #fff;
}

.tool-panel {
  display: none;
  padding: 12px;
  border-radius: 18px;
}

.tool-panel.active {
  display: block;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span em {
  margin-left: 4px;
  color: #9b9188;
  font-style: normal;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #ff9b45;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.14);
}

.search-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  box-shadow: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.help-details {
  padding: 8px 10px;
  border: 1px dashed #eee0d4;
  border-radius: 12px;
  color: var(--muted);
  background: #fffdfa;
  font-size: 13px;
  line-height: 1.55;
}

.help-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}

.help-details p {
  margin: 8px 0 0;
}

.help-details label {
  margin-top: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.plain-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  font-weight: 850;
}

.primary-button {
  color: #fff;
  background: linear-gradient(145deg, #ff8a1f, #f04b00);
  box-shadow: 0 9px 20px rgba(240, 75, 0, 0.24);
}

.secondary-button,
.plain-button {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.accent-button {
  color: var(--orange-dark);
  border-color: #ff9b45;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.plain-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--orange-dark);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 2px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
}

.room-list {
  display: grid;
  gap: 10px;
}

.room-card {
  display: grid;
  gap: 12px;
  padding: 13px;
  border-radius: 16px;
}

.room-card.hidden {
  display: none;
}

.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.room-title {
  min-width: 0;
}

.room-title strong {
  display: block;
  font-size: 19px;
  line-height: 1.2;
}

.room-title small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.open {
  color: var(--green);
  background: #eaf8f1;
}

.badge.ready,
.badge.locked {
  color: var(--orange-dark);
  background: #fff0df;
}

.badge.risk,
.badge.closed {
  color: var(--red);
  background: #fff0f0;
}

.progress {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #f0e6dd;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb15d, #ff6a00);
  transition: width 0.22s ease;
}

.room-meta,
.member-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.room-meta div,
.member-row {
  min-width: 0;
  padding: 9px;
  border-radius: 12px;
  background: #fbf8f5;
  border: 1px solid #f0e6dd;
}

.room-meta strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mine-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mine-stat {
  min-width: 0;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  text-align: center;
}

.mine-stat.active {
  border-color: #ffe2c8;
  background: var(--surface-warm);
}

.mine-stat span {
  display: block;
  min-height: 28px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.mine-stat strong {
  display: block;
  margin-top: 5px;
  color: var(--orange-dark);
  font-size: 20px;
}

.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  padding: 18px;
}

.modal.open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(37, 29, 24, 0.42);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  border-radius: 18px;
  padding: 16px;
}

.sheet-panel {
  align-self: end;
}

.modal-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-panel h2 {
  margin: 0;
  font-size: 18px;
}

.rules-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.modal-copy {
  margin: 0 0 10px;
  line-height: 1.5;
}

.manual-copy,
.invite-box {
  width: 100%;
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.past-answer-list {
  display: grid;
  gap: 9px;
}

.past-answer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf5;
}

.past-answer-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.past-answer-item span {
  color: #ff4b00;
  font-size: 18px;
  font-weight: 850;
  white-space: nowrap;
}

.detail-summary {
  display: grid;
  gap: 12px;
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.member-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  top: max(14px, env(safe-area-inset-top));
  z-index: 100;
  max-width: min(360px, calc(100vw - 32px));
  transform: translate(-50%, -20px);
  padding: 11px 14px;
  border-radius: 14px;
  color: #fff;
  background: rgba(37, 29, 24, 0.94);
  box-shadow: 0 16px 34px rgba(37, 29, 24, 0.22);
  font-size: 14px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

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

@media (max-width: 390px) {
  .hero-card h1 {
    font-size: 28px;
  }

  .hero-meta,
  .room-meta {
    grid-template-columns: 1fr;
  }

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

  .two-col,
  .button-row,
  .room-actions,
  .guide-head {
    grid-template-columns: 1fr;
  }

  .tabs {
    top: 57px;
  }
}
