:root {
  color-scheme: dark;
  --bg: #17191f;
  --surface: #232730;
  --surface-2: #2d313b;
  --surface-3: #151920;
  --line: #3d4350;
  --line-strong: #576070;
  --text: #f5f7fb;
  --muted: #aab2c0;
  --accent: #24c6a2;
  --accent-2: #ffcc4d;
  --danger: #ff6b6b;
  --blue: #53a7ff;
  --preview-cell: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1d23;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #323846;
  font-weight: 800;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #3b4352;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid #303641;
  background: rgba(23, 25, 31, 0.96);
  backdrop-filter: blur(10px);
}

.site-header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  width: min(1180px, calc(100vw - 28px));
  min-height: 62px;
  margin: 0 auto;
}

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

.brand-mark {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
}

.brand-puyo {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  box-shadow:
    inset -3px -4px 0 rgba(0, 0, 0, 0.18),
    inset 3px 3px 0 rgba(255, 255, 255, 0.16);
}

.brand-puyo:nth-child(1) {
  top: 0;
  left: 0;
}

.brand-puyo:nth-child(2) {
  top: 0;
  right: 0;
}

.brand-puyo:nth-child(3) {
  bottom: 0;
  left: 0;
}

.brand-puyo:nth-child(4) {
  right: 0;
  bottom: 0;
}

.brand-puyo.red,
.preview-cell.puyo-red {
  background: var(--danger);
}

.brand-puyo.blue,
.preview-cell.puyo-blue {
  background: var(--blue);
}

.brand-puyo.green,
.preview-cell.puyo-green {
  background: #35d07f;
}

.brand-puyo.yellow,
.preview-cell.puyo-yellow {
  background: #ffd34f;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand-copy small {
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 900;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 22px;
}

.primary-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  color: var(--text);
}

.primary-nav a[aria-current="page"]::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  content: "";
  background: var(--accent);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.session-user {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.session-user-button {
  display: inline-flex;
  max-width: 190px;
  min-height: 36px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
}

.session-user-button:hover,
.session-user-button[aria-current="page"] {
  border-color: var(--line);
  color: var(--text);
  background: #252a33;
}

.session-user-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utility-menu {
  flex: 0 0 auto;
}

.menu-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #252a33;
}

.menu-button:hover:not(:disabled),
.menu-button[aria-expanded="true"],
.menu-button[aria-current="page"] {
  border-color: var(--accent);
  background: #303743;
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}

.site-announcement {
  --announce-accent: var(--accent);
  border-top: 1px solid #303641;
  border-bottom: 1px solid #303641;
  background: #151920;
}

.site-announcement.is-success {
  --announce-accent: #35d07f;
}

.site-announcement.is-warning {
  --announce-accent: var(--accent-2);
}

.site-announcement.is-danger {
  --announce-accent: var(--danger);
}

.site-announcement-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(1180px, calc(100vw - 28px));
  min-height: 42px;
  margin: 0 auto;
  padding: 7px 0;
}

.site-announcement-badge {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--announce-accent);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--announce-accent);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  font-weight: 950;
  white-space: nowrap;
}

.site-announcement-copy {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.site-announcement-title {
  color: var(--text);
  font-size: 0.84rem;
}

.site-announcement-body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.menu-page {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.menu-titlebar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.menu-titlebar h1 {
  font-size: 1.58rem;
  line-height: 1.25;
}

.menu-back-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  background: #252a33;
  font-size: 0.82rem;
  font-weight: 850;
}

.menu-back-link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.site-menu-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.site-menu-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--text);
  background: #151920;
  text-align: left;
}

.site-menu-item:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1d232c;
}

.site-menu-item strong,
.site-menu-item small {
  display: block;
  min-width: 0;
}

.site-menu-item strong {
  font-size: 0.92rem;
  line-height: 1.3;
}

.site-menu-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.menu-item-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-2);
  background: #20242c;
  font-size: 0.95rem;
  font-weight: 950;
}

.copyright-section {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.copyright-section h2 {
  font-size: 1rem;
}

.license-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151920;
}

.license-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.license-table th,
.license-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}

.license-table tr:last-child td {
  border-bottom: 0;
}

.license-table th {
  color: var(--muted);
  background: #20242c;
  font-size: 0.72rem;
  font-weight: 900;
}

.license-table td:first-child {
  font-weight: 850;
}

.rating-section {
  color: var(--text);
}

.rating-copy {
  display: grid;
  gap: 8px;
  max-width: 860px;
}

.rating-copy p,
.rating-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.75;
}

.rating-formula-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #151920;
}

.rating-formula-panel p {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0;
}

.rating-formula-panel span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.rating-formula-panel code {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #20242c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.rating-table td {
  line-height: 1.55;
}

.rating-sample-table {
  min-width: 760px;
}

.rating-change-plus,
.rating-change-minus {
  font-weight: 950;
}

.rating-change-plus {
  color: var(--accent);
}

.rating-change-minus {
  color: var(--danger);
}

.rating-note {
  max-width: 860px;
}

.presence-dot,
.ready-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(36, 198, 162, 0.55);
}

.lobby-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 16px;
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.lobby-surface,
.match-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(35, 39, 48, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.lobby-surface {
  min-width: 0;
  overflow: hidden;
}

.lobby-surface-footer {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
  background: #20242c;
}

.footer-ad-slot {
  display: grid;
  width: min(728px, 100%);
  height: 90px;
  place-items: center;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151920;
}

.footer-ad-slot .adsbygoogle {
  width: 100%;
  height: 90px;
}

.footer-ad-mock {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px;
  color: var(--muted);
  background:
    linear-gradient(90deg, rgba(36, 198, 162, 0.1), transparent 48%, rgba(255, 204, 77, 0.08)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 8px, transparent 8px 16px),
    #151920;
  text-align: center;
}

.footer-ad-mock span {
  font-size: 0.7rem;
  font-weight: 900;
}

.footer-ad-mock strong {
  color: var(--text);
  font-size: 1.08rem;
}

.footer-ad-mock small {
  font-size: 0.72rem;
  font-weight: 750;
}

.lobby-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 92px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #20242c;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
}

.lobby-titlebar h1 {
  font-size: 1.45rem;
  line-height: 1.25;
}

.online-stats {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 22px;
  text-align: right;
}

.online-stats div {
  display: grid;
  gap: 3px;
}

.online-stats dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.online-stats dd {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 0.82rem;
}

.online-stats strong {
  font-size: 1.1rem;
}

.lobby-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: #1d2129;
}

.lobby-tab {
  position: relative;
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
}

.lobby-tab:last-child {
  border-right: 0;
}

.lobby-tab:hover:not(:disabled) {
  border-color: var(--line);
  color: var(--text);
  background: #252a33;
}

.lobby-tab.is-active {
  color: var(--text);
  background: #252a33;
}

.lobby-tab.is-active::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 3px;
  content: "";
  background: var(--accent-2);
}

.lobby-panel {
  min-height: 390px;
  padding: 16px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.preset-option {
  position: relative;
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 130px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 16px;
  text-align: left;
  background: #252a33;
}

.preset-option:hover:not(:disabled) {
  border-color: var(--line);
  background: #2d333e;
}

.preset-option.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent-2);
  background: #30343c;
}

.preset-option .ready-dot {
  position: absolute;
  top: 12px;
  right: 12px;
}

.preset-code {
  color: var(--accent-2);
  font-size: 0.68rem;
  font-weight: 900;
}

.preset-option strong {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.preset-option small {
  min-height: 2.4em;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.45;
}

.match-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.75fr);
  gap: 0;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #20242c;
}

.range-control,
.toggle-control {
  min-height: 94px;
  padding: 15px;
}

.range-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 12px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.range-control output {
  color: var(--text);
}

.range-control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.toggle-control > span:first-child {
  display: grid;
  gap: 3px;
}

.toggle-control strong {
  font-size: 0.82rem;
}

.toggle-control small {
  color: var(--muted);
  font-size: 0.68rem;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #151920;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.toggle-control input:checked + .toggle-track {
  border-color: var(--accent);
  background: rgba(36, 198, 162, 0.18);
}

.toggle-control input:checked + .toggle-track i {
  background: var(--accent);
  transform: translateX(20px);
}

.toggle-control input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.room-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--line);
}

.room-toolbar h2,
.friend-section h2 {
  font-size: 1rem;
}

.room-toolbar p,
.friend-section p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.2rem;
}

.icon-button.is-refreshing {
  animation: refresh-spin 0.45s ease;
}

.room-table-wrap {
  overflow-x: auto;
}

.room-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.room-table th,
.room-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  white-space: nowrap;
}

.room-table th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.room-table td {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
}

.room-table td.is-unrated {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.room-table th:nth-child(1) {
  width: 26%;
}

.room-table th:nth-child(2) {
  width: 26%;
}

.room-table th:nth-child(3),
.room-table th:nth-child(4) {
  width: 14%;
}

.room-table th:last-child {
  width: 20%;
}

.room-table td:first-child .presence-dot {
  margin-right: 7px;
}

.room-empty td {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.join-room-button {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  color: #101318;
  border-color: var(--accent-2);
  background: var(--accent-2);
}

.join-room-button:hover:not(:disabled) {
  color: #101318;
  border-color: #ffe08a;
  background: #ffe08a;
}

.friend-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 340px;
  border: 1px solid var(--line);
  background: #20242c;
}

.friend-section {
  min-width: 0;
  padding: 24px;
}

.friend-section + .friend-section {
  border-left: 1px solid var(--line);
}

.secondary-button {
  width: 100%;
  min-height: 42px;
  margin-top: 22px;
}

.room-code-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--line);
  padding: 10px;
  background: #151920;
}

.room-code-result > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.room-code-result strong {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
}

.invite-url {
  overflow: hidden;
  color: var(--text);
  font-size: 0.72rem;
  text-decoration: underline;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-url:hover {
  color: var(--accent-2);
}

.friend-room-link {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #d9a82d;
  border-radius: 6px;
  padding: 0 10px;
  color: #17130a;
  background: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.friend-room-link:hover {
  border-color: #ffd96d;
  background: #ffd96d;
}

.room-code-form {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.room-code-form label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.room-code-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.room-code-form input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #151920;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
}

.room-code-form button {
  min-width: 78px;
}

.form-error {
  min-height: 1.4em;
  color: #ff9aa3;
  font-size: 0.72rem;
}

.match-panel {
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.match-panel-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  color: var(--muted);
  background: #1d2129;
  font-size: 0.75rem;
  font-weight: 800;
}

.match-panel-header strong {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.queue-state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(36, 198, 162, 0.55);
}

.battle-preview {
  display: grid;
  grid-template-columns: auto 24px auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 184px;
  border-bottom: 1px solid var(--line);
  background: #191d24;
}

.preview-field {
  display: grid;
  grid-template-columns: repeat(6, var(--preview-cell));
  grid-template-rows: repeat(8, var(--preview-cell));
  gap: 2px;
  border: 1px solid #101318;
  border-radius: 6px;
  padding: 6px;
  background: #101318;
}

.preview-cell {
  width: var(--preview-cell);
  height: var(--preview-cell);
  border-radius: 4px;
  background: #252a34;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.preview-cell[class*="puyo-"] {
  border-radius: 50%;
  box-shadow:
    inset -3px -4px 0 rgba(0, 0, 0, 0.18),
    inset 3px 3px 0 rgba(255, 255, 255, 0.2);
}

.versus-mark {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-align: center;
}

.selected-match {
  min-height: 110px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.selected-match h2 {
  font-size: 1.25rem;
}

.selected-match > p:last-child {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.match-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line);
}

.match-summary div {
  min-height: 68px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.match-summary div:nth-child(2n) {
  border-right: 0;
}

.match-summary div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.match-summary dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.match-summary dd {
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 850;
}

.search-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  background: rgba(36, 198, 162, 0.08);
}

.search-progress > div {
  display: grid;
  gap: 3px;
}

.search-progress strong {
  font-size: 0.8rem;
}

.search-progress span:last-child {
  color: var(--muted);
  font-size: 0.69rem;
}

.search-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(36, 198, 162, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: search-spin 0.78s linear infinite;
}

.match-actions {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.primary-button,
.danger-button {
  min-height: 46px;
}

.primary-button {
  border-color: var(--accent-2);
  color: #101318;
  background: var(--accent-2);
}

.primary-button:hover:not(:disabled) {
  border-color: #ffe08a;
  color: #101318;
  background: #ffe08a;
}

.danger-button {
  border-color: rgba(255, 107, 107, 0.7);
  color: #ffc2c7;
  background: rgba(255, 107, 107, 0.12);
}

.danger-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.2);
}

body.is-searching .queue-state-dot {
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(255, 204, 77, 0.7);
  animation: queue-pulse 1.1s ease-in-out infinite;
}

body.is-searching .battle-preview {
  box-shadow: inset 0 0 0 1px rgba(255, 204, 77, 0.24);
}

body.is-searching .opponent-field .preview-cell[class*="puyo-"] {
  animation: opponent-scan 1.35s ease-in-out infinite alternate;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(320px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 11px 14px;
  color: var(--text);
  background: #252a33;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  font-size: 0.78rem;
  font-weight: 750;
}

@keyframes search-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes queue-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.86);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@keyframes opponent-scan {
  from {
    filter: brightness(0.78);
  }
  to {
    filter: brightness(1.32);
  }
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 940px) {
  .site-header-inner {
    gap: 18px;
  }

  .lobby-app {
    grid-template-columns: 1fr;
  }

  .match-panel {
    position: static;
    order: -1;
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) 1fr;
  }

  .match-panel-header {
    grid-column: 1 / -1;
  }

  .battle-preview {
    grid-row: 2 / span 3;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .selected-match,
  .match-summary,
  .search-progress,
  .match-actions {
    grid-column: 2;
  }
}

@media (max-width: 680px) {
  .site-header-inner {
    grid-template-columns: 1fr auto;
    gap: 12px;
    min-height: 58px;
  }

  .brand-copy small {
    display: none;
  }

  .session-user-button {
    max-width: 132px;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 40px;
    gap: 24px;
  }

  .site-header-inner {
    padding-top: 8px;
  }

  .lobby-app {
    padding-top: 12px;
  }

  .lobby-titlebar {
    align-items: flex-start;
    padding: 15px;
  }

  .lobby-titlebar h1 {
    font-size: 1.2rem;
  }

  .online-stats {
    gap: 12px;
  }

  .online-stats dt {
    display: none;
  }

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

  .preset-option {
    min-height: 118px;
    padding: 13px;
  }

  .match-filters,
  .friend-layout {
    grid-template-columns: 1fr;
  }

  .range-control {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .menu-titlebar {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-menu-actions {
    grid-template-columns: 1fr;
  }

  .rating-formula-panel p {
    grid-template-columns: 1fr;
  }

  .friend-section + .friend-section {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .match-panel {
    display: block;
  }

  .battle-preview {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 460px) {
  .lobby-app,
  .menu-page,
  .site-announcement-inner,
  .site-header-inner {
    width: min(1180px, calc(100% - 18px));
  }

  .lobby-surface-footer {
    padding: 10px;
  }

  .footer-ad-mock {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .header-actions {
    gap: 6px;
  }

  .session-user-button {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .session-user-button span:last-child {
    display: none;
  }

  .lobby-titlebar {
    display: grid;
  }

  .online-stats {
    width: 100%;
    text-align: left;
  }

  .online-stats dd {
    justify-content: flex-start;
  }

  .lobby-tab {
    min-height: 44px;
    padding: 0 5px;
    font-size: 0.74rem;
  }

  .lobby-panel {
    padding: 10px;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .preset-option {
    min-height: 104px;
  }

  .room-table th:nth-child(1) {
    width: 25%;
  }

  .room-table th:nth-child(2) {
    width: 21%;
  }

  .room-table th:nth-child(3) {
    width: 15%;
  }

  .room-table th:nth-child(4) {
    width: 15%;
  }

  .room-table th:nth-child(3),
  .room-table td:nth-child(3),
  .room-table th:nth-child(4),
  .room-table td:nth-child(4) {
    padding-right: 4px;
    padding-left: 4px;
  }

  .room-table th:last-child {
    width: 24%;
  }

  .friend-section {
    padding: 18px;
  }

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

  .friend-room-link {
    grid-column: 1 / -1;
  }
}
