/*
 * Panel-style dialogs (game options, preferences). Applied through the
 * "felt-dialog" class, which those dialogs add to their jQuery UI wrapper.
 * Loaded by both the lobby and the game page.
 */

.ui-widget-overlay {
  background: #0B2A1E;
  opacity: 0.72;
}

body .ui-dialog.felt-dialog {
  width: min(480px, calc(100vw - 24px)) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  bottom: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 20px;
  background: #F8F3E6;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  color: #1B1F1C;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

.felt-dialog .ui-dialog-titlebar { display: none; }

.felt-dialog .ui-dialog-content {
  padding: 0;
  overflow: visible;
  background: transparent;
}

/* ---------- Header ---------- */

.felt-dialog .fd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 4px;
}

.felt-dialog .fd-title {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.felt-dialog .fd-sub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: #5B5F59;
}

.felt-dialog .fd-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0 -8px 0 0 !important;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: #3A3E39 !important;
  cursor: pointer;
}

.felt-dialog .fd-close:hover { background: rgba(0, 0, 0, 0.06) !important; }

/* The close button takes focus when a dialog opens; only show a ring for
   keyboard users */
.felt-dialog .fd-close:focus:not(:focus-visible) { outline: none; }

/* ---------- Sections and rows ---------- */

.felt-dialog .fd-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 12px 24px 4px;
}

.felt-dialog .fd-section {
  padding: 14px 16px 6px;
  border: 1px solid #E6DECB;
  border-radius: 14px;
  background: #FBF9F4;
}

.felt-dialog .fd-h {
  margin: 0 0 2px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.felt-dialog .dialog-row {
  box-sizing: border-box;
  width: auto;
  min-height: 54px;
  margin: 0;
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 0;
}

/* A divider only where another visible row follows (some rows are hidden) */
.felt-dialog .dialog-row:has(~ .dialog-row:not([style*="display: none"])) {
  border-bottom: 1px solid #EEE8DC;
}

.felt-dialog .dialog-row > label:not(.ui-checkboxradio-label) {
  font-size: 14px;
  font-weight: 600;
  color: #1B1F1C;
}

/* Number fields */
.felt-dialog input[type="number"] {
  box-sizing: border-box;
  width: 110px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #CFC5B1;
  border-radius: 10px;
  background: #fff;
  color: #1B1F1C;
  font-family: inherit;
  font-size: 14px;
  text-align: right;
}

.felt-dialog input[type="number"]:focus {
  outline: 2px solid #1E6B4F;
  outline-offset: 1px;
}

/* Drop-downs (jQuery UI selectmenu) */
.felt-dialog .ui-selectmenu-button.ui-button {
  box-sizing: border-box;
  width: auto !important;
  min-width: 180px;
  max-width: 62%;
  height: 40px;
  margin: 0;
  padding: 0 34px 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #CFC5B1 !important;
  border-radius: 10px !important;
  background: #fff !important;
  background-image: none !important;
  color: #1B1F1C !important;
  box-shadow: none !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.felt-dialog .ui-selectmenu-button.ui-button:hover { background: #FBF7EE !important; }

.felt-dialog .ui-selectmenu-button .ui-selectmenu-text {
  margin: 0;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.felt-dialog .ui-selectmenu-button .ui-selectmenu-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  margin-top: -8px;
}

/* The drop-down list itself is attached to <body> */
body .ui-selectmenu-menu .ui-menu {
  padding: 4px;
  border: 1px solid #E6DECB;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
}

body .ui-selectmenu-menu .ui-menu .ui-menu-item-wrapper {
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1B1F1C;
}

body .ui-selectmenu-menu .ui-menu .ui-state-active,
body .ui-selectmenu-menu .ui-menu .ui-menu-item-wrapper:hover {
  border: 0;
  background: #E9F2EC;
  color: #1E4A3B;
  margin: 0;
}

/* Switches (jQuery UI checkboxradio, restyled) */
.felt-dialog label.ui-checkboxradio-label.ui-button {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  color: #1B1F1C !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.felt-dialog .ui-checkboxradio-icon-space { display: none; }

.felt-dialog .ui-checkboxradio-label .ui-checkboxradio-icon {
  order: 2;
  position: relative;
  flex: none;
  width: 44px !important;
  height: 26px !important;
  margin: 0 0 0 16px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #CFC5B1 !important;
  background-image: none !important;
  transition: background 0.15s;
}

.felt-dialog .ui-checkboxradio-label .ui-checkboxradio-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.felt-dialog .ui-checkboxradio-label.ui-checkboxradio-checked .ui-checkboxradio-icon {
  background: #1E6B4F !important;
}

.felt-dialog .ui-checkboxradio-label.ui-checkboxradio-checked .ui-checkboxradio-icon::after {
  transform: translateX(18px);
}

/* ---------- Footer ---------- */

.felt-dialog .fd-foot { padding: 16px 24px 24px; }

.felt-dialog .fd-save,
.felt-dialog .fd-primary {
  box-sizing: border-box;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 22px;
  border: 0 !important;
  border-radius: 12px !important;
  background: #F2A23A !important;
  background-image: none !important;
  color: #2A1A05 !important;
  box-shadow: 0 3px 0 #B8701A !important;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.felt-dialog .fd-save:hover,
.felt-dialog .fd-primary:hover { background: #F5AE50 !important; }
.felt-dialog .fd-save:active,
.felt-dialog .fd-primary:active { transform: translateY(1px); }
.felt-dialog .fd-save:disabled,
.felt-dialog .fd-primary:disabled { opacity: 0.5; cursor: default; }

@media screen and (max-width: 480px) {
  .felt-dialog .fd-head { padding: 16px 16px 4px; }
  .felt-dialog .fd-body { padding: 10px 16px 4px; }
  .felt-dialog .fd-foot { padding: 14px 16px 18px; }
  .felt-dialog .ui-selectmenu-button.ui-button { min-width: 150px; }
}


/* ---------- Game details ---------- */

.felt-dialog .gd-players {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.felt-dialog .gd-player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -8px;
  padding: 10px 8px;
  border-radius: 12px;
}

.felt-dialog .gd-player.is-turn {
  background: #FFF4DF;
  box-shadow: inset 0 0 0 2px #E58E1A;
}

.felt-dialog .gd-av {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.felt-dialog .gd-av.is-robot { background: #E2D8C3; color: #3A3E39; }

.felt-dialog .gd-av.is-empty {
  border: 2px dashed #B9AE97;
  background: transparent;
  color: #5B5F59;
  box-sizing: border-box;
}

.felt-dialog .gd-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.felt-dialog .gd-who b { font-size: 15px; font-weight: 600; }
.felt-dialog .gd-who span { font-size: 12px; color: #5B5F59; }
.felt-dialog .gd-player.is-turn .gd-who span { color: #7A4A0A; font-weight: 600; }
.felt-dialog .gd-player.is-empty .gd-who span { font-size: 14px; }

.felt-dialog .gd-score {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 26px;
  font-weight: 700;
}

.felt-dialog .gd-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.felt-dialog .gd-primary,
.felt-dialog .gd-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* A group whose buttons are all hidden takes no space */
.felt-dialog .gd-primary:not(:has(> button:not([style*="display: none"]))),
.felt-dialog .gd-secondary:not(:has(> button:not([style*="display: none"]))) {
  display: none;
}

.felt-dialog .gd-primary .fd-primary { flex: 1 1 0; }

.felt-dialog .fd-secondary {
  flex: 1 1 auto;
  height: 44px;
  margin: 0;
  padding: 0 16px !important;
  border: 1px solid #CFC5B1 !important;
  border-radius: 12px !important;
  background: #fff !important;
  background-image: none !important;
  color: #2A2E29 !important;
  box-shadow: none !important;
  font-family: inherit;
  font-size: 14px !important;
  font-weight: 600;
  cursor: pointer;
}

.felt-dialog .fd-secondary:hover { background: #FBF7EE !important; }

.felt-dialog .gd-danger {
  align-self: center;
  height: 40px;
  margin: 2px 0 0;
  padding: 0 14px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: #A3321F !important;
  font-family: inherit;
  font-size: 14px !important;
  font-weight: 600;
  cursor: pointer;
}

.felt-dialog .gd-danger:hover { background: rgba(200, 67, 46, 0.1) !important; }

.felt-dialog .gd-danger.is-armed {
  background: #C8432E !important;
  color: #fff !important;
}

/* ---------- Invite players ---------- */

.felt-dialog input[type="email"] {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #CFC5B1;
  border-radius: 10px;
  background: #fff;
  color: #1B1F1C;
  font-family: inherit;
  font-size: 14px;
}

.felt-dialog input[type="email"]:focus,
.felt-dialog textarea:focus {
  outline: 2px solid #1E6B4F;
  outline-offset: 1px;
}

.felt-dialog .dialog-row .fd-secondary { flex: none; height: 40px; }

.felt-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid #CFC5B1;
  border-radius: 10px;
  background: #fff;
  color: #1B1F1C;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.felt-dialog .gd-invited { min-height: 0; }
.felt-dialog .gd-invited:has(#invitedPlayers:empty) { display: none; }
.felt-dialog .gd-message { padding-bottom: 14px; }

.felt-dialog .fd-hint {
  margin-bottom: 8px;
  font-size: 12px;
  color: #5B5F59;
}

.felt-dialog .invitee {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #E9F2EC;
  color: #1E4A3B;
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
  cursor: pointer;
}

.felt-dialog .invitee:after { content: "  \00D7"; }
.felt-dialog .invitee:last-child:after { content: "  \00D7"; }

/* Text fields (e.g. the name when watching a game) */
.felt-dialog input[type="text"] {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  max-width: 260px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #CFC5B1;
  border-radius: 10px;
  background: #fff;
  color: #1B1F1C;
  font-family: inherit;
  font-size: 14px;
}

.felt-dialog input[type="text"]:focus {
  outline: 2px solid #1E6B4F;
  outline-offset: 1px;
}

/* ---------- Notices (alerts, connection messages) ---------- */

.felt-dialog .fd-alert {
  margin: 0;
  padding: 8px 0 4px;
  font-size: 15px;
  line-height: 1.5;
  color: #1B1F1C;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.felt-dialog .fd-body:has(.fd-alert) { padding-top: 4px; }

/* ---------- Blank tile picker ---------- */

.felt-dialog .fd-body:has(.bd-grid) { padding-bottom: 24px; }

.bd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 10px;
  padding: 10px 0 0;
}

.bd-letter {
  aspect-ratio: 1 / 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #F6E2AE;
  color: #24190C;
  box-shadow: inset 0 -4px 0 rgba(120, 84, 20, 0.3), 0 2px 3px rgba(0, 0, 0, 0.12);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s, background 0.12s;
}

.bd-letter:hover { background: #FBECC4; transform: translateY(-2px); }
.bd-letter:active { transform: translateY(0); }

/* ---------- Password field ---------- */

.felt-dialog input[type="password"] {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #CFC5B1;
  border-radius: 10px;
  background: #fff;
  color: #1B1F1C;
  font-family: inherit;
  font-size: 14px;
}

.felt-dialog input[type="password"]:focus {
  outline: 2px solid #1E6B4F;
  outline-offset: 1px;
}

.felt-dialog button.hide-password {
  position: static !important;
  flex: none;
  width: 40px !important;
  height: 40px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid #CFC5B1 !important;
  border-radius: 10px !important;
  background-color: #fff !important;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 20px;
  box-shadow: none !important;
}
