:root {
  color-scheme: dark;
  font-family: "Noto Sans JP", "Noto Sans CJK JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1324;
  color: #f5f7ff;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 280px;
  min-height: 100svh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgb(90 119 255 / 28%), transparent 35rem),
    linear-gradient(180deg, #121a30 0%, #0d1324 62%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 0 20px;
  background: #7188ff;
  color: #071029;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  background: #303a55;
  color: #8992a8;
  cursor: not-allowed;
}

input,
textarea {
  width: 100%;
  border: 1px solid #35415f;
  border-radius: 14px;
  background: #111a2f;
  color: #f5f7ff;
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
  letter-spacing: 0.22em;
  font-size: 1.1rem;
  font-weight: 700;
}

input::placeholder {
  color: #737e98;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

textarea {
  resize: vertical;
  min-height: 72px;
  padding: 12px 14px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: #8ea0ff;
  box-shadow: 0 0 0 3px rgb(113 136 255 / 20%);
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding:
    max(28px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.app-header {
  max-width: 660px;
  margin: 0 auto;
  padding: 12px 4px 22px;
  text-align: center;
}

.section-kicker {
  margin: 0 0 5px;
  color: #aebaff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 10vw, 3.3rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.lead,
.hint,
.privacy-note {
  color: #aeb7cc;
  line-height: 1.6;
}

.lead {
  margin-bottom: 0;
  color: #d4daf0;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 600;
}

.card {
  max-width: 520px;
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 14px;
  border: 1px solid rgb(154 171 255 / 18%);
  border-radius: 22px;
  padding: 20px;
  background: rgb(20 29 51 / 88%);
  box-shadow: 0 18px 50px rgb(0 0 0 / 20%);
  backdrop-filter: blur(14px);
}

.chat-card {
  max-width: 820px;
  padding: clamp(18px, 3vw, 28px);
}

.chat-card[hidden],
.count[hidden] {
  display: none;
}

.room-card--joined {
  max-width: 820px;
}

.section-heading,
.join-row,
.send-actions,
.room-actions {
  display: flex;
  align-items: center;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 18px;
}

.count {
  border: 1px solid #3a496d;
  border-radius: 999px;
  padding: 6px 10px;
  color: #cbd3ff;
  font-size: 0.82rem;
  font-weight: 800;
}

.room-actions {
  gap: 8px;
}

.button-secondary {
  min-height: 34px;
  border: 1px solid #53638c;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: #d9e0ff;
  font-size: 0.78rem;
}

.button-secondary:disabled {
  border-color: #35415f;
  background: transparent;
}

.secondary-button {
  width: 100%;
  margin-top: 12px;
  border: 1px solid #53638c;
  background: transparent;
  color: #d9e0ff;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #dce1f1;
  font-size: 0.85rem;
  font-weight: 700;
}

.join-row {
  gap: 9px;
}

.join-row button {
  flex: 0 0 auto;
  min-width: 88px;
  padding-right: 24px;
  padding-left: 24px;
  letter-spacing: 0.04em;
}

.create-room-section {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.action-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #8791a8;
  font-size: 0.75rem;
  text-align: center;
}

.action-divider::before,
.action-divider::after {
  height: 1px;
  background: #35415f;
  content: "";
  flex: 1;
}

.create-button {
  width: 100%;
  border: 1px solid #7188ff;
  background: transparent;
  color: #cbd3ff;
}

.create-button:disabled {
  border-color: #35415f;
  background: transparent;
}

.active-room {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 12px;
  margin-top: 18px;
  border: 1px solid #3a496d;
  border-radius: 16px;
  padding: 12px 14px;
  background: #111a2f;
}

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

.active-room-label {
  color: #aeb7cc;
  font-size: 0.75rem;
}

.active-room-code {
  grid-row: 2;
  color: #f5f7ff;
  font-size: 1.45rem;
  letter-spacing: 0.18em;
}

.active-room .button-secondary {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  border-radius: 14px;
  padding: 12px 13px;
  background: #222d48;
  color: #d9deec;
  font-size: 0.84rem;
  line-height: 1.45;
}

.status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f0bc59;
  box-shadow: 0 0 0 4px rgb(240 188 89 / 12%);
}

.status--ready .status-dot {
  background: #73d7a5;
  box-shadow: 0 0 0 4px rgb(115 215 165 / 12%);
}

.status--error .status-dot {
  background: #ff7f91;
  box-shadow: 0 0 0 4px rgb(255 127 145 / 12%);
}

.message-list {
  display: flex;
  min-height: clamp(280px, 48svh, 560px);
  max-height: 58svh;
  margin: 0 0 14px;
  padding: 12px;
  overflow-y: auto;
  border: 1px solid #2d3855;
  border-radius: 16px;
  background: #0e172a;
  list-style: none;
  flex-direction: column;
  gap: 8px;
}

.empty-message,
.message-empty {
  margin: auto;
  color: #7f899f;
  text-align: center;
  line-height: 1.6;
  font-size: 0.85rem;
}

.message-item {
  display: flex;
  width: 100%;
}

.message-item:first-child {
  margin-top: auto;
}

.message-item--local {
  justify-content: flex-end;
}

.message-item--remote {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border: 1px solid #34415f;
  border-radius: 14px;
  background: #17233b;
  color: #e9edf7;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: pre-wrap;
}

.message-item--local .message-bubble {
  border-color: #526da8;
  background: #263b68;
}

.send-actions {
  justify-content: space-between;
  margin-top: 9px;
  gap: 12px;
  flex-wrap: wrap;
}

.character-count {
  color: #8791a8;
  font-size: 0.78rem;
}

.send-actions #send-button {
  flex: 0 0 auto;
  margin-left: auto;
}

.privacy-note {
  margin: 18px 8px 0;
  text-align: center;
  color: #c0c8dc;
  font-size: 0.82rem;
  font-weight: 600;
}

.first-steps {
  max-width: 520px;
  margin: 22px auto 0;
  color: #99a4bd;
}

.first-steps[hidden] {
  display: none;
}

.first-steps h2 {
  margin-bottom: 11px;
  color: #aeb7cc;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-align: center;
}

.first-steps ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.first-steps li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
}

.first-steps li span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  border: 1px solid #46557a;
  border-radius: 50%;
  color: #b9c4f5;
  font-size: 0.7rem;
  font-weight: 800;
  place-items: center;
  flex: 0 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 360px) {
  .card {
    padding: 16px;
  }

  .join-row {
    align-items: stretch;
    flex-direction: column;
  }

  .join-row button,
  .send-actions #send-button {
    width: 100%;
  }

  .first-steps ol {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .first-steps li {
    justify-content: flex-start;
    max-width: 230px;
    width: 100%;
    margin: 0 auto;
    text-align: left;
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding-right: max(28px, env(safe-area-inset-right));
    padding-left: max(28px, env(safe-area-inset-left));
  }

  .active-room {
    grid-template-columns: auto 1fr auto;
  }

  .active-room-code {
    grid-column: 2;
    grid-row: 1;
  }

  .active-room .button-secondary {
    grid-column: 3;
    grid-row: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
