:root {
  --mm-line: rgba(255, 255, 255, 0.12);
  --mm-muted: #c5d0ea;
  --mm-panel-top: rgba(126, 181, 255, 0.34);
  --mm-panel-bg-a: rgba(255, 255, 255, 0.08);
  --mm-panel-bg-b: rgba(255, 255, 255, 0.035);
  --mm-panel-bg-c: rgba(8, 16, 33, 0.82);
  --mm-focus: rgba(132, 172, 255, 0.78);
  --mm-focus-ring: rgba(132, 172, 255, 0.2);
  --mm-success-bg: rgba(50, 197, 128, 0.14);
  --mm-warn-bg: rgba(255, 193, 95, 0.12);
  --mm-loading-bg: rgba(137, 169, 252, 0.14);
}

.match-shell {
  padding-bottom: 56px;
}

.match-layout {
  display: grid;
  gap: 18px;
}

@media (min-width: 1120px) {
  .match-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-layout > .match-panel:nth-child(3),
  .match-layout > .match-panel:nth-child(4) {
    grid-column: 1 / -1;
  }
}

.match-panel {
  position: relative;
  border-radius: 22px;
  border: 1px solid var(--mm-line);
  background:
    linear-gradient(180deg, var(--mm-panel-bg-a), var(--mm-panel-bg-b)),
    var(--mm-panel-bg-c);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  padding: 18px 18px 17px;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  animation: panel-enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.match-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mm-panel-top), transparent);
}

.match-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.34);
  border-color: rgba(255, 255, 255, 0.2);
}

.match-layout > .match-panel:nth-child(2) {
  animation-delay: 40ms;
}

.match-layout > .match-panel:nth-child(3) {
  animation-delay: 80ms;
}

.match-layout > .match-panel:nth-child(4) {
  animation-delay: 120ms;
}

.match-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.match-head h2 {
  margin: 3px 0 0;
  font-size: 1.26rem;
  line-height: 1.25;
}

.match-sub {
  margin: 0;
  color: var(--mm-muted);
  font-size: 0.93rem;
  line-height: 1.62;
}

.match-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.match-grid.match-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.match-field {
  display: grid;
  gap: 7px;
}

.match-field span {
  font-size: 0.82rem;
  color: var(--mm-muted);
  font-weight: 700;
}

.match-field input,
.match-field select {
  width: 100%;
  min-height: 46px;
  border-radius: 13px;
  border: 1px solid var(--mm-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.04);
  color: #f7f8ff;
  padding: 11px 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.match-field input:focus,
.match-field select:focus {
  border-color: var(--mm-focus);
  box-shadow: 0 0 0 3px var(--mm-focus-ring);
}

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

.match-actions .btn {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.match-actions .btn:hover {
  transform: translateY(-1px);
}

.match-actions .btn:active {
  transform: translateY(0);
}

.match-note {
  margin-top: 12px;
  color: var(--mm-muted);
  font-size: 0.83rem;
  line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
  padding: 10px 12px;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

.match-note[data-state="ok"] {
  color: #8ef2be;
  border-color: rgba(142, 242, 190, 0.28);
  background: var(--mm-success-bg);
}

.match-note[data-state="warn"] {
  color: #ffd7a4;
  border-color: rgba(255, 189, 109, 0.28);
  background: var(--mm-warn-bg);
}

.match-note[data-state="loading"] {
  color: #d1dcfb;
  border-color: rgba(145, 178, 255, 0.3);
  background: var(--mm-loading-bg);
}

.public-room-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.public-room-card {
  border-radius: 16px;
  border: 1px solid var(--mm-line);
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.public-room-card:hover {
  transform: translateY(-1px);
  border-color: rgba(174, 199, 255, 0.42);
  box-shadow: 0 8px 18px rgba(3, 11, 30, 0.3);
  background: rgba(255, 255, 255, 0.055);
}

.public-room-card.is-new {
  border-color: rgba(142, 242, 190, 0.72);
  box-shadow: 0 0 0 1px rgba(142, 242, 190, 0.4);
}

.public-room-main {
  min-width: 0;
}

.public-room-code {
  font-size: 1.03rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #f4f7ff;
  word-break: break-all;
}

.public-room-meta {
  margin-top: 5px;
  font-size: 0.82rem;
  color: var(--mm-muted);
  line-height: 1.45;
}

.public-room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.public-room-watch {
  text-decoration: none;
  color: #c7d8ff;
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 1px dashed rgba(199, 216, 255, 0.4);
}

.public-room-watch:hover {
  color: #ffffff;
  border-bottom-color: rgba(199, 216, 255, 0.8);
}

.public-room-join {
  min-height: 40px;
  min-width: 92px;
  border-radius: 10px;
}

.public-room-empty {
  border-radius: 16px;
  border: 1px dashed var(--mm-line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--mm-muted);
  text-align: center;
  line-height: 1.5;
  padding: 18px 12px;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 940px) {
  .match-grid {
    grid-template-columns: 1fr;
  }

  .match-panel:hover {
    transform: none;
  }
}

@media (max-width: 720px) {
  .code-row {
    grid-template-columns: 1fr;
  }

  .match-actions .btn {
    width: 100%;
  }

  .public-room-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .public-room-actions {
    width: 100%;
  }

  .public-room-join {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .match-panel,
  .match-actions .btn,
  .public-room-card {
    animation: none !important;
    transition: none !important;
  }
}
