:root {
  --bg: #0c0c0e;
  --panel: #17171a;
  --panel2: #1f1f23;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #8e8e96;
  --blue: #3b82f6;
  --gold: #e0b34a;
  --tab: 3.75rem;
  --safe: env(safe-area-inset-bottom, 0px);
  --font: "Noto Sans SC", system-ui, sans-serif;
  --display: "Syne", var(--font);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding-bottom: calc(var(--tab) + var(--safe));
}
.view.is-active { display: flex; }
.view[hidden] { display: none !important; }
.view.room { padding-bottom: calc(var(--tab) + 4.2rem + var(--safe)); }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.65rem;
  padding: 0.3rem 0.55rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 14, 0.94);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 8;
}
.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 700;
}
.room-h { font-size: 0.82rem !important; }
.top-spacer { width: 2.2rem; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 0;
  background: var(--panel2);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  color: var(--text);
}
.pill-btn.ghost { opacity: 0.55; }

.scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.pad { padding: 1rem; }

.section-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem 0.3rem;
  font-weight: 700;
  font-size: 0.82rem;
}
.section-label .count,
.section-label .badge {
  margin-left: auto;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.7rem;
}
.section-label .badge {
  background: var(--panel2);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.ann-wrap { padding: 0 0.75rem 0.25rem; }
.ann-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 0.5rem;
  border-radius: 0.7rem;
  scrollbar-width: none;
}
.ann-track::-webkit-scrollbar { display: none; }
.ann-track img {
  flex: 0 0 100%;
  width: 100%;
  height: 7.5rem;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: center;
  border-radius: 0.7rem;
  scroll-snap-align: start;
  border: 1px solid rgba(224, 179, 74, 0.25);
}
.ann-dots {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.ann-dots button {
  width: 0.32rem;
  height: 0.32rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  padding: 0;
}
.ann-dots button.on { background: var(--blue); width: 0.7rem; border-radius: 999px; }

.game-card {
  margin: 0 0.75rem 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  overflow: hidden;
}
.game-thumb {
  position: relative;
  border: 0;
  padding: 0;
  width: 100%;
  background: #000;
  display: block;
}
.game-thumb img {
  width: 100%;
  height: 6.75rem;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: center;
  opacity: 0.88;
}
.game-thumb-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: linear-gradient(180deg, transparent 25%, rgba(0,0,0,0.55));
}
.g88 {
  font-family: var(--display);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 0.9;
  background: linear-gradient(180deg, #fff6d4, #d4a017);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gname {
  font-family: var(--display);
  letter-spacing: 0.1em;
  font-weight: 800;
  font-size: 0.78rem;
}
.gcn { color: var(--gold); letter-spacing: 0.14em; font-size: 0.7rem; margin-top: 0.1rem; }

.game-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem 0.2rem;
}
.game-meta h3 { margin: 0; font-size: 0.88rem; }
.game-meta p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.68rem; }
.howto-btn {
  border: 0;
  background: var(--panel2);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
}
.enter-btn {
  margin: 0.4rem 0.7rem 0.7rem;
  width: calc(100% - 1.4rem);
  border: 0;
  border-radius: 0.65rem;
  padding: 0.65rem;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
}

.wallet-hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.1rem;
  margin-bottom: 0.85rem;
}
.muted { color: var(--muted); margin: 0; font-size: 0.82rem; }
.bal {
  margin: 0.25rem 0 0.9rem;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
}
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.blue { background: var(--blue); color: #fff; }
.btn.dark { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.sm { padding: 0.6rem 0.9rem; font-size: 0.88rem; }
.btn.block { width: 100%; margin-top: 1rem; }

.list-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
}
.list-row {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.foot-hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.9rem; }

.chat-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.av {
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.85rem;
}
.av.gold { background: linear-gradient(145deg, #3a2a10, #1a1208); color: var(--gold); border: 1px solid rgba(224,179,74,.45); }
.av.red { background: #3a1212; color: #f5b5b5; border: 1px solid #a61f2d; }
.av.blue { background: #122033; color: #93c5fd; border: 1px solid #3b82f6; }
.ci-top { display: flex; justify-content: space-between; gap: 0.5rem; }
.ci-title { font-weight: 700; font-size: 0.95rem; }
.ci-time { color: var(--muted); font-size: 0.72rem; }
.ci-prev { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.v {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--blue);
  vertical-align: middle;
  position: relative;
}
.v::after {
  content: "";
  position: absolute;
  left: 0.22rem;
  top: 0.15rem;
  width: 0.28rem;
  height: 0.45rem;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}

.me-page { text-align: center; }
.me-av {
  width: 4.6rem;
  height: 4.6rem;
  margin: 0.4rem auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  background: linear-gradient(145deg, #f3d78a, #8a6a28);
  color: #1a1208;
}
.me-name { margin: 0.4rem 0 0; font-weight: 700; font-size: 1.15rem; }
.me-uid { margin: 0.2rem 0 1rem; color: var(--muted); font-size: 0.85rem; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-bottom: 0.85rem; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.85rem;
  text-align: left;
}
.stat span { display: block; color: var(--muted); font-size: 0.72rem; }
.stat strong { font-family: var(--display); font-size: 1.45rem; }
.me-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.45rem;
}
.me-menu button {
  border: 0;
  background: transparent;
  padding: 1rem 0.4rem;
  border-radius: 0.75rem;
}
.version { color: var(--muted); font-size: 0.75rem; margin-top: 1.1rem; }

.howto h2 { margin: 1rem 0 0.35rem; font-size: 1.05rem; }
.howto p { margin: 0; color: var(--muted); line-height: 1.5; }
.howto-hero { border-radius: 0.9rem; border: 1px solid rgba(224,179,74,.3); margin-bottom: 0.5rem; }

.pin {
  margin: 0.5rem 0.75rem 0;
  padding: 0.4rem 0.65rem;
  border-radius: 0.6rem;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 0.74rem;
}
.feed {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.bubble-wrap { max-width: 92%; }
.bubble-wrap.me { align-self: flex-end; }
.bubble-wrap .who { font-size: 0.7rem; color: var(--muted); margin: 0 0 0.15rem 0.2rem; }
.bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.45;
}
.bubble-wrap.me .bubble { background: #1a3358; border-color: rgba(59,130,246,.35); }
.bubble img { width: 100%; border-radius: 0.5rem; margin-bottom: 0.4rem; }
.sys { align-self: center; color: var(--muted); font-size: 0.74rem; text-align: center; }

.packet-card {
  width: 100%;
  border: 0;
  border-radius: 0.85rem;
  padding: 0.85rem 0.9rem 0.95rem;
  text-align: left;
  background: linear-gradient(160deg, #c62828 0%, #8b1515 55%, #5c0d0d 100%);
  color: #ffe8c2;
  box-shadow: 0 10px 24px rgba(140, 20, 20, 0.35);
  cursor: pointer;
}
.packet-card:disabled {
  opacity: 0.7;
  cursor: default;
}
.packet-card .pk-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.packet-card .pk-seal {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #ffd98a, #c4891a);
  color: #5c2e00;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.85rem;
}
.packet-card .pk-title {
  font-weight: 800;
  font-size: 0.95rem;
}
.packet-card .pk-sub {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 0.1rem;
}
.packet-card .pk-cta {
  margin-top: 0.65rem;
  display: inline-flex;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.75rem;
  font-weight: 700;
}

.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--tab) + var(--safe));
  display: flex;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  background: rgba(12,12,14,0.96);
  border-top: 1px solid var(--line);
  max-width: 480px;
  margin: 0 auto;
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.7rem 0.95rem;
  outline: none;
}

.support-center {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 0.45rem;
  text-align: center;
  padding: 1.5rem;
}
.sup-ico {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  background: #122033;
  color: #93c5fd;
  font-family: var(--display);
  font-weight: 800;
  box-shadow: 0 0 24px rgba(59,130,246,0.25);
}
.support-center h2 { margin: 0.3rem 0 0; }
.support-center p { margin: 0; color: var(--muted); }
.tiny { font-size: 0.75rem !important; }

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--tab) + var(--safe));
  padding: 0.3rem 0.4rem var(--safe);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 20, 22, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  max-width: 480px;
  margin: 0 auto;
}
.tabbar button {
  border: 0;
  background: transparent;
  color: #6f6f78;
  display: grid;
  justify-items: center;
  gap: 0.05rem;
  font-size: 0.62rem;
  padding: 0.2rem;
}
.tabbar button.is-on { color: #fff; }
.tabbar svg { width: 18px; height: 18px; }

.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.55);
  padding: 1.2rem;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(100%, 19.5rem);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem 1.1rem 1rem;
  text-align: center;
}
.shield {
  width: 2.8rem;
  height: 2.8rem;
  margin: 0 auto 0.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  font-weight: 800;
  font-size: 0.75rem;
}
.modal-card h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.modal-card p { margin: 0 0 1rem; color: var(--muted); font-size: 0.88rem; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
