:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --surface-tint: #fff7f8;
  --line: #e3e8ef;
  --line-strong: #cfd8e3;
  --text: #182230;
  --muted: #697586;
  --faint: #98a4b3;
  --rose: #e7697d;
  --rose-dark: #c94f64;
  --mint: #2f9f8f;
  --mint-soft: #e6f6f3;
  --blue: #5d79d8;
  --gold: #bd7b22;
  --red: #d94d55;
  --green: #238a62;
  --shadow: 0 6px 18px rgba(24, 34, 48, 0.055);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 247, 248, 0.82), rgba(246, 247, 251, 0) 150px),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.user-app {
  width: min(100%, 640px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 8px 10px calc(74px + env(safe-area-inset-bottom));
}

.boot-card,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.boot-card {
  margin-top: 24px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  margin: -8px -10px 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(227, 232, 239, 0.88);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

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

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

.room-heading strong {
  display: block;
  color: var(--text);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: #182230;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

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

.brand-copy strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-copy span,
.muted {
  color: var(--muted);
  font-size: 11px;
}

.room-select {
  width: 100%;
  min-height: 32px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok {
  color: var(--green);
  border-color: rgba(35, 138, 98, 0.26);
  background: #edf8f3;
}

.pill.warn {
  color: var(--gold);
  border-color: rgba(189, 123, 34, 0.28);
  background: #fff7e8;
}

.content {
  display: grid;
  gap: 8px;
}

.card {
  min-width: 0;
  padding: 10px;
}

.section-head {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head > div {
  flex: 1 1 0;
  min-width: 0;
}

.section-head h2 {
  font-size: 14px;
  line-height: 1.25;
}

.section-head .btn {
  flex: 0 0 auto;
  max-width: 86px;
  padding-right: 8px;
  padding-left: 8px;
  font-size: 12px;
}

.section-head p {
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card,
.auth-card {
  display: grid;
  gap: 9px;
  border-color: #efd6db;
  background:
    linear-gradient(135deg, rgba(255, 247, 248, 0.98), rgba(230, 246, 243, 0.75)),
    var(--surface);
}

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

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--mint-soft);
  color: var(--mint);
  font-size: 19px;
  font-weight: 900;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  min-width: 0;
}

.profile-name h1 {
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.name-meta {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 800;
  white-space: nowrap;
}

.profile-name p {
  color: var(--muted);
  font-size: 11px;
}

.level-block {
  display: grid;
  gap: 5px;
}

.level-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.level-line strong {
  font-size: 21px;
  line-height: 1;
}

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

.progress span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--mint));
}

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

.metric {
  display: grid;
  gap: 1px;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  font-size: 16px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.auth-actions,
.segmented,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.ranking-hero {
  display: grid;
  gap: 2px;
  border-color: #efd6db;
  background:
    linear-gradient(135deg, rgba(255, 247, 248, 0.98), rgba(230, 246, 243, 0.72)),
    var(--surface);
}

.ranking-hero > div:first-child {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 2px;
  color: var(--rose-dark);
  font-size: 11px;
  font-weight: 900;
}

.ranking-hero h2 {
  font-size: 20px;
  line-height: 1.1;
}

.ranking-hero p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-controls {
  display: grid;
  gap: 7px;
}

.control-row {
  display: grid;
  gap: 4px;
}

.control-row > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 4px;
}

.rank-chip {
  min-width: 0;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.rank-chip.active {
  border-color: #182230;
  background: #182230;
  color: #ffffff;
}

.rank-chip:disabled {
  color: var(--faint);
  cursor: not-allowed;
  background: #f2f4f7;
}

.btn {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.btn.primary {
  background: var(--rose);
  border-color: var(--rose);
  color: #ffffff;
  font-weight: 900;
}

.btn.ghost {
  background: transparent;
}

.btn.active {
  color: #ffffff;
  background: #182230;
  border-color: #182230;
  font-weight: 900;
}

.btn:disabled {
  color: var(--faint);
  cursor: not-allowed;
  background: #f2f4f7;
}

.code-box {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px dashed rgba(231, 105, 125, 0.45);
  border-radius: var(--radius);
  background: rgba(255, 247, 248, 0.92);
}

.code {
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 3px;
}

.command {
  font-family: Consolas, "Cascadia Code", monospace;
  color: var(--rose-dark);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.rank-list,
.title-list,
.activity-list {
  display: grid;
  gap: 5px;
}

.podium-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  margin-bottom: 7px;
}

.podium-card {
  min-width: 0;
  min-height: 86px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.podium-card.podium-rank-1 {
  min-height: 98px;
  border-color: #efd6db;
  background:
    linear-gradient(180deg, rgba(255, 247, 248, 1), rgba(255, 255, 255, 0.96)),
    var(--surface);
}

.podium-no {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.podium-rank-1 .podium-no {
  color: #ffffff;
  background: var(--rose);
}

.podium-card strong {
  max-width: 100%;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.podium-card .name-meta {
  display: block;
  margin: 2px 0 0;
}

.podium-card span {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.podium-card small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-empty {
  min-height: 116px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 18px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.ranking-empty strong {
  font-size: 14px;
}

.ranking-empty span {
  color: var(--muted);
  font-size: 12px;
}

.rank-item,
.title-item,
.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rank-item.top {
  border-color: #efd6db;
  background: var(--surface-tint);
}

.rank-item.no-rank {
  grid-template-columns: minmax(0, 1fr) auto;
}

.rank-item.no-rank.top {
  border-color: var(--line);
  background: var(--surface);
}

.rank-no {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.rank-item.top .rank-no {
  color: #ffffff;
  background: var(--rose);
}

.item-main {
  min-width: 0;
}

.item-main strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.2;
  font-size: 13px;
}

.item-main span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.item-main .name-meta {
  display: inline-block;
  margin-top: 0;
  margin-left: 5px;
}

.rank-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.title-item {
  grid-template-columns: minmax(0, 1fr) auto;
}

.title-item.owned {
  border-color: rgba(47, 159, 143, 0.34);
  background: var(--mint-soft);
}

.empty {
  padding: 14px 8px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--red);
}

.text-input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 7px 9px;
  outline: none;
}

.text-input:focus {
  border-color: rgba(231, 105, 125, 0.72);
  box-shadow: 0 0 0 3px rgba(231, 105, 125, 0.13);
}

.field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.code-input {
  text-transform: uppercase;
  font-family: Consolas, "Cascadia Code", monospace;
  font-weight: 900;
  letter-spacing: 1px;
}

.rps-card {
  display: grid;
  gap: 10px;
  border-color: #efd6db;
  background:
    linear-gradient(135deg, rgba(255, 247, 248, 0.98), rgba(249, 250, 252, 0.96)),
    var(--surface);
}

.rps-list-card {
  background: var(--surface);
}

.rps-start-grid {
  display: grid;
}

.rps-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  color: var(--faint);
  font-size: 11px;
  font-weight: 900;
}

.rps-divider::before,
.rps-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.rps-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed rgba(231, 105, 125, 0.45);
  border-radius: var(--radius);
  background: rgba(255, 247, 248, 0.9);
}

.rps-code-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.rps-code-box strong {
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

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

.rps-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.rps-list-main {
  min-width: 0;
}

.rps-list-main > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.rps-list-main strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rps-list-main .pill {
  flex: 0 0 auto;
}

.rps-list-main p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.rps-versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

.rps-player {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 86px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rps-player.you {
  border-color: rgba(47, 159, 143, 0.34);
  background: var(--mint-soft);
}

.rps-player.empty {
  border-style: dashed;
  color: var(--muted);
  background: var(--surface-soft);
}

.rps-player span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.rps-player strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.2;
}

.rps-player small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.rps-vs {
  display: grid;
  place-items: center;
  color: var(--rose-dark);
  font-size: 12px;
  font-weight: 900;
}

.rps-note,
.rps-result {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.rps-result {
  border-color: rgba(231, 105, 125, 0.28);
  background: var(--surface-tint);
  color: var(--rose-dark);
  font-size: 16px;
}

.rps-result.draw {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.rps-moves {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.rps-move {
  min-width: 0;
  min-height: 66px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.rps-move span {
  font-size: 22px;
  line-height: 1;
}

.rps-move strong {
  font-size: 12px;
}

.rps-move.active {
  border-color: #182230;
  background: #182230;
  color: #ffffff;
}

.rps-move:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.bamboo-card {
  display: grid;
  gap: 10px;
}

.bamboo-input {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px;
  outline: none;
}

.bamboo-input:focus {
  border-color: rgba(231, 105, 125, 0.72);
  box-shadow: 0 0 0 3px rgba(231, 105, 125, 0.13);
}

.bamboo-list {
  display: grid;
  gap: 7px;
}

.bamboo-post {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.bamboo-post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bamboo-post-head strong {
  color: var(--rose-dark);
  font-size: 12px;
}

.bamboo-post-head span {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.bamboo-post p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.bottom-tabs {
  position: fixed;
  right: max(10px, calc((100vw - 640px) / 2 + 10px));
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(10px, calc((100vw - 640px) / 2 + 10px));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(24, 34, 48, 0.105);
  backdrop-filter: blur(14px);
}

.tab {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.tab.active {
  background: #182230;
  color: #ffffff;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 78px;
  left: 12px;
  z-index: 40;
  max-width: 520px;
  margin: 0 auto;
  display: none;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #182230;
  color: #ffffff;
  box-shadow: var(--shadow);
}

@media (min-width: 680px) {
  .content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .profile-card,
  .auth-card,
  .content > .card:first-child {
    grid-column: 1 / -1;
  }

  .content.view-ranking > .card,
  .content.view-game > .card,
  .content.view-bamboo > .card,
  .content.view-profile > .card,
  .content.view-titles > .card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .user-app {
    padding-right: 8px;
    padding-left: 8px;
  }

  .app-header {
    margin-right: -8px;
    margin-left: -8px;
    padding-right: 8px;
    padding-left: 8px;
  }

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

  .btn {
    flex: 0 0 auto;
  }

  .rank-item,
  .activity-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rank-value {
    grid-column: 2;
    justify-self: start;
  }

  .rank-item.no-rank {
    grid-template-columns: minmax(0, 1fr);
  }

  .rank-item.no-rank .rank-value {
    grid-column: 1;
  }
}
