:root {
  --bg: #ffffff;
  --card: #ffffff;
  --line: #ececec;
  --text: #141414;
  --sub: #6d6d6d;
  --primary: #ffd233;
  --primary-ink: #141414;
  --danger: #ff4d4f;
  --shadow: 0 16px 40px rgba(20, 20, 20, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -20%, #fff3b8 0, transparent 34%),
    radial-gradient(circle at 96% 6%, #fff8d9 0, transparent 30%),
    var(--bg);
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.splash-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 210, 51, 0.45) 0, rgba(255, 210, 51, 0) 70%);
  animation: splashGlow 1.4s ease-in-out infinite;
}

.splash-content {
  position: relative;
  text-align: center;
  animation: splashRise 0.75s ease forwards;
}

.splash-icon {
  font-size: 44px;
  color: #d5a200;
  animation: splashBeat 1s ease-in-out infinite;
}

.splash-title {
  font-size: 30px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.splash-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--sub);
}

.splash-screen.leave {
  animation: splashFadeOut 0.45s ease forwards;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 14px 96px;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 6px;
  background: transparent;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

.hint {
  color: var(--sub);
  font-size: 13px;
  line-height: 1.45;
}

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

#authPanel {
  min-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 24px;
}

.auth-step {
  border: 1px solid #ffe8a2;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffef8 0%, #ffffff 100%);
  padding: 18px;
  gap: 18px;
}

.auth-error {
  border: 1px solid #ffc9c9;
  color: #c91f1f;
  background: #fff4f4;
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
button {
  font-size: 15px;
  font-family: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #fff;
}

input:focus {
  outline: none;
  border-color: #ffd233;
  box-shadow: 0 0 0 3px rgba(255, 210, 51, 0.2);
}

button {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}

.small {
  padding: 8px 10px;
}

.primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: #ffd233;
}

.danger {
  background: #fff3f3;
  color: var(--danger);
  border-color: #ffcaca;
}

.ghost {
  background: #fff;
  border-color: #ffd233;
  color: var(--text);
}

.wide-btn {
  width: min(360px, 100%);
  min-height: 48px;
}

.centered {
  margin: 14px auto 0;
  display: block;
}

.icon-back {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  color: #444;
}

.code-digits {
  display: grid;
  grid-template-columns: repeat(6, minmax(40px, 1fr));
  gap: 8px;
}

.code-digit {
  text-align: center;
  padding: 12px 4px;
  font-size: 20px;
  font-weight: 700;
  border-color: #ffe79a;
  background: #fffdf4;
}

.custom-select {
  position: relative;
}

.select-trigger {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  padding: 11px 12px;
}

.select-options {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  border: 1px solid #ffe7a0;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
}

.select-options button {
  border: none;
  border-radius: 10px;
  background: #fff;
  text-align: left;
  padding: 8px 10px;
}

.select-options button:hover {
  background: #fff8d8;
}

.tab-content {
  display: none;
  margin-top: 16px;
}

.tab-content.active {
  display: block;
}

.card,
.list > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.match-card {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-color: #f0e1aa;
  border-radius: 16px;
  padding: 16px;
}

.match-card h3,
.match-card .hint,
.match-card div {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.match-card-success {
  background-image: linear-gradient(rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.82)), url('/match-success.svg');
}

.match-card-failed {
  background-image: linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.86)), url('/match-failed.svg');
}

.match-card-matching {
  background-image: linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.86)), url('/match-matching.svg');
}

.match-card-waiting {
  background-image: linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.88)), url('/match-not-joined.svg');
}

.match-illustration {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  margin: 8px 0;
  object-fit: cover;
  background: #fffdf4;
}

.match-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.card-action {
  width: min(280px, 100%);
  margin: 14px auto 2px;
  display: block;
  border: 1px solid #ffd233;
  background: #fffdf1;
  min-height: 48px;
  font-weight: 600;
}

.card-action.center {
  margin-left: auto;
  margin-right: auto;
}

.chat-empty-text {
  margin: 8px 2px 4px;
  color: var(--sub);
  font-size: 14px;
}

.list > .card {
  cursor: pointer;
}

#chatHeader {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#chatTitle {
  font-size: 16px;
  font-weight: 600;
}

.messages {
  min-height: 240px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  border-radius: 12px;
  padding: 6px 2px 106px;
  background: transparent;
}

.msg {
  margin: 8px 0;
}

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

.bubble {
  display: inline-block;
  max-width: 82%;
  border-radius: 14px;
  padding: 9px 11px;
  border: 1px solid #efefef;
  background: #fafafa;
}

.msg.me .bubble {
  background: #fff7cf;
  border-color: #ffe79a;
}

.bubble img {
  max-width: 100%;
  border-radius: 10px;
}

.composer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 74px;
  width: min(760px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.composer input {
  border: none;
  box-shadow: none;
  background: transparent;
}

.file-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid #ffd233;
  background: #fffef4;
}

.send-round {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ffd233;
  border: 1px solid #ffd233;
}

.text-action {
  background: transparent;
  border: none;
  padding: 0;
  color: #5f4b00;
  text-decoration: underline;
  text-underline-offset: 3px;
  width: fit-content;
}

.profile-line {
  display: grid;
  grid-template-columns: 26px 90px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border-bottom: 1px dashed #f1f1f1;
}

.profile-line:last-child {
  border-bottom: none;
}

.profile-icon {
  color: #cda000;
  font-size: 16px;
}

.profile-value {
  color: #2d2d2d;
}

.edit-mini {
  border: 1px solid #ffe08f;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: #fffdf2;
  padding: 0;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 30;
  padding: 6px 8px;
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 10px 6px;
  color: var(--sub);
  font-size: 13px;
  cursor: pointer;
  border-radius: 12px;
}

.nav-item.active {
  color: #1b1b1b;
  background: #fff6cf;
}

.nav-item.active i {
  color: #cda000;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.34);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 60;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid #ffe19a;
  border-radius: 18px;
  box-shadow: 0 22px 50px rgba(20, 20, 20, 0.2);
  padding: 16px;
}

.modal-card h3 {
  margin-top: 0;
}

@media (max-width: 560px) {
  .app {
    padding: 12px 10px 90px;
  }

  #authPanel {
    min-height: calc(100vh - 150px);
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .messages {
    max-height: calc(100vh - 250px);
  }

  .composer {
    width: calc(100vw - 16px);
    bottom: 66px;
  }
}

@keyframes splashBeat {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.1);
  }
}

@keyframes splashRise {
  0% {
    transform: translateY(14px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes splashGlow {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@keyframes splashFadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}
