:root {
  --bg0: #f4f6f8;
  --bg1: #e8ecf1;
  --ink: #1a1d24;
  --muted: #6b7280;
  --line: rgba(26, 29, 36, 0.1);
  --accent: #9a7b4a;
  --accent-bright: #c4a574;
  --accent-soft: rgba(154, 123, 74, 0.12);
  --accent-ink: #fffaf3;
  --danger: #b45a4c;
  --panel: rgba(255, 255, 255, 0.78);
  --surface: #ffffff;
  --font: "DM Sans", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1000px 640px at 0% 0%, #dde5f0 0%, transparent 55%),
    radial-gradient(900px 560px at 100% 0%, #efe6d8 0%, transparent 50%),
    radial-gradient(700px 480px at 50% 100%, #e4ebe8 0%, transparent 45%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 60%, #e2e7ed);
  background-attachment: fixed;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
  padding: 20px 18px 40px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
  animation: rise 0.6s ease both;
}

.brand-mark {
  display: block;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  color: var(--ink);
}

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 4px;
}

.tickets {
  font-size: 0.8rem;
  padding: 6px 10px;
  border: 1px solid rgba(154, 123, 74, 0.35);
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  white-space: nowrap;
  font-weight: 600;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-block {
  padding: 8px 0 4px;
  animation: rise 0.7s 0.05s ease both;
}

.logo {
  margin: 0;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, #1a1d24 10%, #6b5530 45%, var(--accent) 75%, #c4a574 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 28ch;
}

.panel {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 18px 40px rgba(26, 29, 36, 0.06);
  animation: rise 0.7s ease both;
}

.panel:nth-of-type(2) { animation-delay: 0.08s; }
.panel:nth-of-type(3) { animation-delay: 0.14s; }
.panel:nth-of-type(4) { animation-delay: 0.2s; }

.panel h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.hint code {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

.hint code.demo-code {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(154, 123, 74, 0.35);
  background: var(--accent-soft);
  letter-spacing: 0.12em;
}

.hint code.demo-code:hover {
  filter: brightness(0.97);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  box-shadow: 0 1px 2px rgba(26, 29, 36, 0.04);
}

input:focus,
select:focus {
  border-color: rgba(154, 123, 74, 0.55);
  box-shadow: 0 0 0 3px rgba(154, 123, 74, 0.12);
}

input.mono {
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.row {
  display: flex;
  gap: 8px;
}

.row input {
  flex: 1;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  border-color: rgba(26, 29, 36, 0.2);
  background: #fafbfc;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(165deg, #d4b483 0%, var(--accent) 48%, #7d6238 100%);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(154, 123, 74, 0.28);
}

.btn.primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 12px 32px rgba(154, 123, 74, 0.34);
}

.btn.wide {
  width: 100%;
  margin-top: 4px;
}

.btn.ghost {
  padding: 8px 12px;
  font-size: 0.8rem;
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(180, 90, 76, 0.35);
}

.msg {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

.foot {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: center;
  animation: rise 0.7s 0.25s ease both;
}

/* —— 独立房间页 —— */
body.room-page {
  height: 100dvh;
  overflow: hidden;
}

.room-shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  height: 100dvh;
  margin: 0 auto;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  animation: rise 0.45s ease both;
}

.room-shell.dimmed {
  filter: blur(2px);
  opacity: 0.35;
  pointer-events: none;
}

.room-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--ink);
}

.room-top-center {
  text-align: center;
  min-width: 0;
}

.room-code {
  font-family: var(--mono);
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--ink);
}

.room-info {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-actions {
  display: flex;
  gap: 6px;
}

.countdown {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  padding: 8px 0 6px;
  text-align: center;
}

.composer-foot {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0;
  border-top: none;
}

.composer input {
  flex: 1;
  min-width: 0;
}

.room-ttl-mini {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin: 0;
  cursor: pointer;
}

.room-ttl-mini select {
  width: auto;
  min-width: 58px;
  max-width: 72px;
  margin: 0;
  padding: 8px 4px;
  font-size: 0.68rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: none;
  line-height: 1.2;
}

.room-composer {
  padding-bottom: 0;
}

.room-status {
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px dashed rgba(154, 123, 74, 0.4);
  border-radius: 12px;
  background: var(--accent-soft);
  animation: rise 0.4s ease both;
}

.room-status p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--accent);
  line-height: 1.4;
  text-align: center;
  font-weight: 500;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 2px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.msg-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 88%;
  animation: pop 0.25s ease both;
}

.msg-row.me {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row .who {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
  padding: 0 2px;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-row.me .who {
  text-align: right;
}

.bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 4px 14px 14px 14px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(26, 29, 36, 0.04);
}

.msg-row.me .bubble {
  border-radius: 14px 4px 14px 14px;
  background: linear-gradient(165deg, #f7f0e4, #efe4d0);
  border-color: rgba(154, 123, 74, 0.28);
}

.bubble .text {
  font-size: 0.95rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-row .ttl {
  margin-top: 4px;
  padding: 0 2px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
  line-height: 1.2;
  background: none;
  border: none;
  box-shadow: none;
}

.msg-row.me .ttl {
  text-align: right;
}

.msg-row.gone {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.system {
  align-self: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.room-boot {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 500px at 50% 18%, rgba(221, 229, 240, 0.95), transparent 60%),
    rgba(244, 246, 248, 0.82);
  backdrop-filter: blur(10px);
}

.room-boot[hidden] {
  display: none;
}

.boot-card {
  width: min(360px, 100%);
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 60px rgba(26, 29, 36, 0.1);
  text-align: center;
  animation: rise 0.35s ease both;
}

.boot-card h1 {
  margin: 0 0 10px;
  font-size: 1.4rem;
  color: var(--ink);
}

.boot-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.boot-card .btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1a1d24;
  border: 1px solid rgba(196, 165, 116, 0.35);
  color: #f3eee6;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 20;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(26, 29, 36, 0.25);
  animation: rise 0.25s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 720px) {
  .app {
    max-width: 480px;
    padding-top: 36px;
  }

  .room-shell {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .room-code {
    font-size: 1.45rem;
  }
}

.admin-app {
  max-width: 560px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.admin-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-count {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
}

.admin-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.admin-code {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.ok {
  background: rgba(60, 120, 90, 0.12);
  color: #2f6b4f;
}

.tag.danger {
  background: rgba(180, 90, 76, 0.12);
  color: var(--danger);
}

.admin-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.admin-enter {
  margin-top: 10px;
}

.admin-gen-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-codes {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

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

.admin-panel-head h2 {
  margin: 0;
}

.admin-toggle {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.admin-vault.is-collapsed .admin-panel-body,
.admin-panel-body[hidden] {
  display: none !important;
}

.admin-panel-head {
  cursor: pointer;
  user-select: none;
}

.admin-vault:not(.is-collapsed) .admin-panel-head {
  margin-bottom: 12px;
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.admin-filter {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.admin-filter.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
}
