/* ── Account panel (floating + embedded-in-menu variants) ────────────── */

.account-panel {
  position: fixed;
  /* Open below the stacked hamburger + profile buttons */
  top: 128px;
  right: 20px;
  padding: 16px;
  background: var(--surface-panel-card-bright);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  z-index: 200;
  width: min(360px, calc(100vw - 24px));
  min-width: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  transform-origin: top right;
}

.menu-panel .account-panel {
  position: static;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.account-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.account-panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #5b3d24;
}

.account-panel__row {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.account-panel__row.online-scroll-list {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
}

.online-scroll-list > .account-btn {
  flex: 0 0 auto;
}

.account-panel__row > .account-btn {
  flex: 1 1 auto;
}

.account-panel__row--split {
  justify-content: flex-end;
}

.account-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--color-brown-muted);
}

.account-inline {
  display: flex;
  gap: 0;
  align-items: center;
}

#auth-save-profile {
  margin-left: 8px;
}

.account-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fffaf2;
  color: var(--color-brown-deep);
}

.account-input:focus {
  outline: none;
  border-color: rgba(101, 67, 33, 0.35);
  box-shadow: 0 0 0 2px rgba(101, 67, 33, 0.12);
}

.account-input--with-prefix {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.account-input-prefix {
  padding: 10px 10px 10px 12px;
  border-radius: 12px 0 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-right: none;
  background: #fffaf2;
  color: var(--color-brown-muted);
  font-size: 14px;
}

.account-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  font-size: 13px;
  color: var(--color-brown-muted);
  cursor: pointer;
}

.account-checkbox-label input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.account-checkbox-label input[type="checkbox"]:disabled ~ span {
  opacity: 0.5;
}

.account-details {
  margin-top: 12px;
}

.account-summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--color-brown-muted);
  padding: 6px 0;
}

.account-summary:hover {
  color: var(--color-brown-deep);
}

.account-password-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.account-btn {
  --account-btn-bg: rgba(255, 255, 255, 0.6);
  --account-btn-hover-bg: rgba(255, 255, 255, 0.8);
  --account-btn-border: 1px solid rgba(0, 0, 0, 0.14);
  --account-btn-color: var(--color-brown-deep);
  padding: 10px 12px;
  border-radius: 12px;
  border: var(--account-btn-border);
  background: var(--account-btn-bg);
  color: var(--account-btn-color);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}

.account-btn:hover:not(:disabled) {
  background: var(--account-btn-hover-bg);
}

.account-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-btn--primary {
  --account-btn-bg: #e4c6a4;
  --account-btn-border: none;
  --account-btn-color: var(--color-brown-deep);
}

.account-btn--ghost {
  --account-btn-bg: transparent;
}

/* Profile panel: align account controls with game menu styling */
#menu-panel-profile .account-panel__title,
#menu-panel-profile .account-label,
#menu-panel-profile .account-summary {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a623f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 4px;
}

#menu-panel-profile .account-panel__header {
  margin-bottom: 6px;
}

#menu-panel-profile .account-panel__row:not(:has(:not(.account-hidden))) {
  display: none;
}

#menu-panel-profile .account-panel__row:not(:has(.account-checkbox-label)),
#online-login-required .account-panel__row {
  gap: 4px;
  margin: 0;
  background: var(--menu-panel-highlight-strong);
  border-radius: 8px;
  padding: 4px;
}

#menu-panel-profile .account-panel__row > .account-btn,
#online-login-required .account-panel__row > .account-btn {
  flex: 1 1 0;
}

#menu-panel-profile .account-btn,
#online-login-required .account-btn {
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-brown-strong);
  font-weight: 600;
}

#menu-panel-profile .account-btn--primary,
#online-login-required .account-btn--primary {
  background: var(--menu-button-active);
  color: var(--color-brown-dark);
}

#menu-panel-profile .account-input,
#menu-panel-profile .account-input-prefix {
  background: #fff6e5;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--color-brown-strong);
}

/* ── Online: invite search results + selection ───────────────────────── */

.online-user-result {
  width: 100%;
  justify-content: space-between;
}

.online-user-result .username {
  font-weight: 700;
}

.online-user-result .user-exists {
  font-size: 12px;
  color: var(--hex-highlight);
}

.online-user-result.selected,
.online-user-result.selected:focus,
.online-user-result.selected:focus-visible,
.online-user-result.selected:active,
.account-btn.selected,
.account-btn.selected:focus,
.account-btn.selected:focus-visible,
.account-btn.selected:active {
  background: var(--menu-selected-bg);
  border-color: rgba(101, 67, 33, 0.35);
}

/* ── Games list rows ─────────────────────────────────────────────────── */

.games-list-row {
  width: 100%;
  justify-content: space-between;
  text-align: left;
  overflow: hidden;
  padding: 10px 12px;
  height: var(--games-list-row-height);
  line-height: 1.2;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.38);
}

.games-list .games-list-row:nth-child(even) {
  background: var(--games-list-row-alt-bg);
}

.games-list-row:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.52);
}

.games-list-row.selected,
.games-list-row.selected:focus,
.games-list-row.selected:focus-visible,
.games-list-row.selected:active {
  background: var(--games-list-row-selected-bg);
  border-color: rgba(101, 67, 33, 0.35);
}

.games-list .games-list-row {
  flex: 0 0 auto;
}

.games-list-opponent {
  font-weight: 700;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-list-result {
  font-size: 12px;
  color: var(--color-brown-muted);
  flex: 0 0 auto;
  white-space: nowrap;
  margin-left: 12px;
}

.games-list-result--win {
  color: var(--hex-highlight);
}

.games-list-result--loss {
  color: #8b1f2b;
}

/* ── Online: inviter toast feedback ──────────────────────────────────── */

.online-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 10000;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-brown-deep);
}

.online-toast--hidden {
  display: none;
}

/* ── Danger / footnote / error ───────────────────────────────────────── */

.account-btn--danger {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.5);
  color: #8b1f2b;
}

.account-danger {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 10px;
  margin-top: 6px;
}

.account-footnote {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--color-brown-muted);
}

.account-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: #b00020;
}

.account-error:empty {
  display: none;
}

#auth-guest-cta {
  text-align: center;
  padding: 12px;
  border: 1px solid rgba(101, 67, 33, 0.12);
  border-radius: 10px;
  background: rgba(255, 253, 246, 0.7);
}

#auth-guest-cta .account-footnote {
  margin: 0 0 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--color-brown-muted);
}

#auth-guest-cta .account-btn--primary {
  width: 100%;
}

.account-protected {
  margin-top: 8px;
}

.account-hidden {
  display: none !important;
}
