.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--gap);
}

body.embed .app {
  max-width: 100%;
  width: 100%;
  padding: 8px 8px 64px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #1d4ed8;
}

.header__subtitle {
  font-size: 13px;
  color: var(--muted);
}

.main {
  display: grid;
  gap: var(--gap);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

body.embed .toolbar {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 8px;
  gap: 6px;
  justify-content: flex-start;
}

body.embed .toolbar__group {
  flex-wrap: wrap;
}

body.embed .toolbar__spacer {
  display: none;
}

.toolbar__group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar__spacer {
  flex: 1;
}

.toolbar__meta {
  font-size: 13px;
  color: var(--muted);
}

.status {
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.status.isError {
  color: var(--danger);
}

.leaderboardHost {
  margin: 6px auto;
  width: 100%;
  max-width: 880px;
  padding: 0 6px;
}

.leaderboardPanel {
  display: grid;
  gap: 10px;
}

body.embed .leaderboardHost {
  width: 100%;
  max-width: 100%;
  padding: 0 8px;
}

.leaderboardCard {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.leaderboardCard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.leaderboardTitle {
  font-weight: 700;
  color: #0f172a;
}

.leaderboardSubtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.leaderboardTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
}

.leaderboardTable th,
.leaderboardTable td {
  text-align: left;
  padding: 6px 8px;
}

.leaderboardTable th {
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.leaderboardTable tbody tr:nth-child(even) {
  background: var(--panel2);
}

.leaderboardActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.leaderboardActions__btns {
  display: flex;
  gap: 6px;
}

.leaderboardNote {
  font-size: 12px;
  color: var(--muted);
}

.leaderboardEmpty {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.leaderboardDateRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.input--sm {
  padding: 8px 10px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.btn:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
}

.btn--ghost {
  background: transparent;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.input {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  font: inherit;
}

.input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.boardWrap {
  position: relative;
  width: min(96vw, 760px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
  touch-action: none;
}

body.embed .boardWrap {
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.modalRoot {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}

.modalRoot.isOpen {
  display: block;
}

.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  width: min(520px, 96vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.modal__title {
  font-weight: 700;
  margin-bottom: 6px;
}

.modal__body {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Embed / iframe mode */
body.embed {
  background: transparent;
}

body.embed .app {
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  padding: 0 4px;
}

body.embed .header {
  display: none;
}

body.embed .toolbar {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 640px;
}

body.embed .toolbar__spacer {
  flex: 0 0 auto;
}

body.embed .toolbar__meta {
  white-space: nowrap;
}

body.embed .boardWrap {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
