/* Makaó multiplayer Phase 1 overlay. Kept separate from the legacy single-player CSS. */
:root {
  --mp-bg: rgba(5, 18, 11, .92);
  --mp-card: rgba(8, 30, 18, .92);
  --mp-border: rgba(244, 217, 132, .32);
  --mp-gold: #f4d984;
  --mp-gold-2: #c99a36;
  --mp-text: #fff7d1;
  --mp-muted: rgba(255, 247, 209, .72);
  --mp-danger: #ffb1a8;
}

#makao-mp-overlay,
#makao-mp-lobby,
#makao-mp-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#makao-mp-overlay,
#makao-mp-lobby {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--mp-text);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 242, 188, .18), transparent 26%),
    radial-gradient(circle at 10% 90%, rgba(18, 98, 61, .45), transparent 34%),
    rgba(3, 10, 6, .92);
  backdrop-filter: blur(8px);
}

.makao-mp-card {
  width: min(760px, 100%);
  max-height: min(92vh, 860px);
  overflow: auto;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid var(--mp-border);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(15, 65, 39, .96), rgba(7, 22, 13, .96));
  box-shadow: 0 26px 90px rgba(0, 0, 0, .52), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.makao-mp-card h1,
.makao-mp-card h2,
.makao-mp-card h3 {
  margin: 0 0 12px;
  color: var(--mp-text);
  letter-spacing: -.02em;
}

.makao-mp-card p {
  margin: 0 0 18px;
  color: var(--mp-muted);
  line-height: 1.55;
}

.makao-mp-mode-card {
  text-align: center;
}

.makao-mp-mode-card p {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.makao-mp-mode-grid,
.makao-mp-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

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

.makao-mp-button,
.makao-mp-input,
.makao-mp-select {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  font: inherit;
}

.makao-mp-button {
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.16);
  color: #1d1305;
  font-weight: 850;
  background: linear-gradient(180deg, #fff0b2 0%, #e4bd55 52%, #a97820 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.46), 0 10px 24px rgba(0,0,0,.30);
}

.makao-mp-button.secondary {
  color: var(--mp-text);
  background: rgba(255,255,255,.07);
  border-color: var(--mp-border);
}

.makao-mp-button.danger {
  color: #320b06;
  background: linear-gradient(180deg, #ffd1cc 0%, #ff9b90 100%);
}

.makao-mp-button:disabled {
  cursor: not-allowed;
  opacity: .55;
  filter: grayscale(.25);
}

.makao-mp-input,
.makao-mp-select {
  border: 1px solid var(--mp-border);
  background: rgba(0,0,0,.28);
  color: var(--mp-text);
  padding: 0 14px;
  outline: none;
}

.makao-mp-field {
  margin: 14px 0;
}

.makao-mp-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--mp-muted);
  font-size: 14px;
  font-weight: 700;
}

.makao-mp-error {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 177, 168, .45);
  border-radius: 14px;
  color: var(--mp-danger);
  background: rgba(80, 12, 8, .30);
}

.makao-mp-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 138px;
  padding: 10px 16px;
  border: 1px solid var(--mp-border);
  border-radius: 14px;
  color: var(--mp-text);
  background: rgba(0,0,0,.28);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .08em;
}

.makao-mp-player-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.makao-mp-player-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(244, 217, 132, .18);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
}

.makao-mp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--mp-text);
  background: rgba(0,0,0,.26);
  font-size: 13px;
}

body.makao-mp-active #fajer-audio-start-overlay { display: none !important; }
body.makao-mp-active #page-card > #js-makao,
body.makao-mp-active #page-card > .time-line,
body.makao-mp-active #page-card > .global-asked-card,
body.makao-mp-active #page-card > .asked-card,
body.makao-mp-active > .szinvalaszto,
body.makao-mp-active > .szamvalaszto,
body.makao-mp-active #page-card > #js-end,
body.makao-mp-active #page-card > .magy-card,
body.makao-mp-active #page-card > .name-button,
body.makao-mp-active #page-card > .speech-bubble-box { display: none !important; }

#makao-mp-root {
  display: none;
  position: relative;
  color: var(--mp-text);
  min-height: calc(var(--fajer-vh, 100vh) - 78px);
  padding: 14px;
}

body.makao-mp-active #makao-mp-root {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.makao-mp-gamebar,
.makao-mp-hand,
.makao-mp-table {
  border: 1px solid rgba(244, 217, 132, .18);
  border-radius: 18px;
  background: rgba(5, 18, 11, .50);
  box-shadow: 0 12px 30px rgba(0,0,0,.20);
}

.makao-mp-gamebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.makao-mp-gamebar strong { color: var(--mp-gold); }

.makao-mp-table {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: 0;
  padding: 12px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.10), rgba(255,255,255,.02) 42%, rgba(0,0,0,.18) 100%),
    linear-gradient(180deg, #16613f 0%, #0f5234 52%, #0c452c 100%);
}

.makao-mp-opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.makao-mp-opponent {
  min-width: 160px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(0,0,0,.22);
  text-align: center;
}

.makao-mp-back-stack {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  min-height: 62px;
}

.makao-mp-back-stack img {
  width: 42px;
  margin-left: -22px;
  border-radius: 4px;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.42));
}

.makao-mp-back-stack img:first-child { margin-left: 0; }

.makao-mp-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 6vw, 60px);
}

.makao-mp-pile {
  text-align: center;
  color: var(--mp-muted);
  font-weight: 700;
}

.makao-mp-card-img {
  width: clamp(72px, 11vw, 120px);
  border-radius: 8px;
  filter: drop-shadow(0 12px 14px rgba(0,0,0,.42));
}

.makao-mp-hand {
  padding: 10px;
}

.makao-mp-hand-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--mp-muted);
}

.makao-mp-card-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  min-height: 124px;
}

.makao-mp-hand-card {
  flex: 0 0 auto;
  width: clamp(72px, 15vw, 112px);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: transform .14s ease, filter .14s ease, opacity .14s ease;
}

.makao-mp-hand-card img {
  width: 100%;
  display: block;
  border-radius: 8px;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,.38));
}

.makao-mp-hand-card:not(.legal) {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.25);
}

.makao-mp-hand-card.legal:hover {
  transform: translateY(-10px);
}

.makao-mp-choice {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,.62);
}

.makao-mp-choice-box {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--mp-border);
  border-radius: 22px;
  color: var(--mp-text);
  background: var(--mp-card);
}

.makao-mp-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 720px) {
  .makao-mp-mode-grid,
  .makao-mp-actions,
  .makao-mp-choice-grid { grid-template-columns: 1fr; }
  .makao-mp-gamebar { align-items: flex-start; flex-direction: column; }
  #makao-mp-root { padding: 8px; }
}

.makao-mp-lobby-status {
  padding: 12px 14px;
  border: 1px solid rgba(244, 217, 132, .20);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
  color: var(--mp-text) !important;
  font-weight: 750;
}

.makao-mp-sync-status {
  margin-top: -6px !important;
  font-size: 13px;
  color: rgba(255, 247, 209, .62) !important;
}

.makao-mp-action-notice {
  margin: 10px 0 0 !important;
  padding: 10px 12px;
  border: 1px solid rgba(244, 217, 132, .28);
  border-radius: 12px;
  color: var(--mp-text) !important;
  background: rgba(0, 0, 0, .22);
  font-weight: 700;
}


/* === Multiplayer native table skin: reuses the legacy single-player table classes without touching the original engine === */
body.makao-mp-active #page-card {
  overflow: hidden;
}

#makao-mp-root.makao-mp-native-table {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  min-height: 0;
  padding: 0;
  color: #fff;
  pointer-events: auto;
  font-family: Open Sans Condensed, system-ui, sans-serif;
}

body.makao-mp-active #makao-mp-root.makao-mp-native-table {
  display: block;
}

.makao-mp-native-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.makao-mp-native-layer .magy-card,
.makao-mp-native-layer .name-button,
.makao-mp-native-layer .speech-bubble-box,
.makao-mp-native-layer .global-asked-card,
.makao-mp-native-layer .asked-card {
  display: block !important;
}

.makao-mp-native-card {
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  box-sizing: border-box;
  background: #fff;
}

.makao-mp-native-card.not-legal {
  opacity: .64;
  filter: grayscale(.18) drop-shadow(0 5px 8px rgba(0,0,0,.34));
}

.makao-mp-native-card.legal,
.makao-mp-stock-card.legal {
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255,255,255,.22), 0 0 16px rgba(255,255,255,.20);
}

.makao-mp-native-card.legal:hover,
.makao-mp-stock-card.legal:hover {
  transform: translateY(-10px);
  filter: drop-shadow(0 15px 15px rgba(0,0,0,.48));
}

.makao-mp-opponent-back {
  opacity: .98;
}

.makao-mp-native-name {
  font-size: 20px;
  line-height: 1;
  text-align: center;
}

.makao-mp-native-name .text {
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  height: 100%;
  line-height: 1.25;
  padding-left: 6px;
  padding-right: 6px;
}

.makao-mp-native-name small {
  font-size: 70%;
  opacity: .75;
}

.makao-mp-native-pile-label {
  position: absolute;
  z-index: 95;
  color: #f7e7ac;
  text-align: center;
  font-size: 16px;
  line-height: 1.05;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  pointer-events: none;
}

.makao-mp-native-global-asked {
  font-weight: 700;
  line-height: 26px;
  min-height: 26px;
  text-shadow: 0 0 1px rgba(0,0,0,.5);
}

.makao-mp-native-asked-img {
  width: 30px;
  height: auto;
}

.makao-mp-native-speech {
  font-size: 18px;
  color: #111;
  pointer-events: none;
}

.makao-mp-native-speech .speech-bubble {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mp-declare,
#mp-draw,
#mp-exit-game,
#mp-final-exit {
  cursor: pointer;
}

#mp-declare.makao-mp-disabled,
#mp-draw.makao-mp-disabled {
  cursor: default;
  opacity: .48;
  filter: grayscale(.2) drop-shadow(0 3px 6px rgba(0,0,0,.30));
}

#mp-declare.makao-mp-disabled .text,
#mp-draw.makao-mp-disabled .text {
  background: linear-gradient(180deg, #b9b096 0%, #7c735a 100%) !important;
  color: rgba(0,0,0,.72);
}

#mp-declare.makao-button.active .text,
#mp-declare.makao-button.active.makao-mp-disabled .text {
  background: linear-gradient(180deg, #6fe09a 0%, #289857 100%) !important;
  color: #08190f !important;
}

#mp-declare.makao-button.active {
  opacity: 1 !important;
  filter: drop-shadow(0 0 8px rgba(60, 255, 120, .42)) drop-shadow(0 3px 6px rgba(0,0,0,.30)) !important;
}


.makao-mp-native-sync {
  position: absolute;
  z-index: 151;
  width: 200px;
  color: rgba(247,231,172,.82);
  text-align: right;
  font-size: 15px;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  pointer-events: none;
}

.makao-mp-native-final {
  position: absolute !important;
  left: 50% !important;
  top: 18% !important;
  transform: translateX(-50%) !important;
}

.makao-mp-native-choice {
  z-index: 100000;
}

.makao-mp-choice .makao-mp-choice-panel,
body.makao-mp-active .makao-mp-choice .szinvalaszto,
body.makao-mp-active .makao-mp-choice .szamvalaszto {
  display: block !important;
  position: relative !important;
  left: auto !important;
  top: auto !important;
  margin: 0 !important;
}

.makao-mp-choice .szinvalaszto img,
.makao-mp-choice .szamvalaszto img {
  transition: transform .12s ease, filter .12s ease;
}

.makao-mp-choice .szinvalaszto img:hover,
.makao-mp-choice .szamvalaszto img:hover {
  transform: translateY(-6px);
  filter: drop-shadow(0 10px 12px rgba(0,0,0,.42));
}

@media (max-width: 800px), (max-height: 500px) {
  .makao-mp-native-name { font-size: 16px; }
  .makao-mp-native-pile-label { font-size: 13px; }
  .makao-mp-native-speech { font-size: 14px; }
  .makao-mp-native-sync { display: none; }
}

@media (max-width: 480px) {
  .makao-mp-native-pile-label { display: none; }
  .makao-mp-native-speech { max-width: 160px; }
}

.makao-mp-native-layer .makao-mp-hand-card {
  position: absolute;
  flex: none;
  padding: 0;
  border: 1px solid #555;
  border-radius: 10px;
  background: #fff;
}

body.makao-mp-active .makao-mp-native-card,
body.makao-mp-active .makao-mp-choice img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body.makao-mp-busy .makao-mp-hand-card.legal,
body.makao-mp-busy #mp-draw,
body.makao-mp-busy #mp-draw-pile,
body.makao-mp-busy #mp-declare,
body.makao-mp-busy .makao-mp-choice img {
  pointer-events: none;
  filter: brightness(.92) saturate(.85);
}

.makao-mp-hand-card.legal,
#mp-draw-pile.legal,
.makao-mp-choice img {
  cursor: pointer;
}


/* Multiplayer initial deal animation */
.makao-mp-deal-layer {
  pointer-events: none;
}

.makao-mp-dealt-placeholder {
  position: absolute;
  border: 1px solid #555;
  border-radius: 10px;
  opacity: .96;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.42));
}

.makao-mp-deal-card {
  position: absolute;
  border: 1px solid #555;
  border-radius: 10px;
  transition: left .46s cubic-bezier(.18,.82,.23,1), top .46s cubic-bezier(.18,.82,.23,1), transform .46s cubic-bezier(.18,.82,.23,1), opacity .25s ease;
  filter: drop-shadow(0 14px 14px rgba(0,0,0,.48));
  will-change: left, top, transform;
  pointer-events: none;
}

.makao-mp-deal-discard {
  background: #fff;
}


/* === Multiplayer finished-state controls === */
.makao-mp-final-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.makao-mp-native-final .makao-mp-final-actions .button-3d {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  display: inline-block;
  min-width: 122px;
  width: auto !important;
  margin: 0 !important;
}
.makao-mp-native-final .makao-mp-final-actions .button-3d .text {
  min-width: 122px;
  padding-left: 12px;
  padding-right: 12px;
  box-sizing: border-box;
}
.makao-mp-native-final .makao-mp-final-new-game .text {
  background: linear-gradient(180deg, #fff0b2 0%, #e2bc54 55%, #a8781e 100%) !important;
  color: #1b1306;
}
@media screen and (max-width: 500px) {
  .makao-mp-final-actions {
    gap: 10px;
  }
  .makao-mp-native-final .makao-mp-final-actions .button-3d,
  .makao-mp-native-final .makao-mp-final-actions .button-3d .text {
    min-width: 98px;
  }
}


/* === Multiplayer restart fix: hide legacy single-player new-game controls === */
body.makao-mp-active #menu .js_new_game,
body.makao-mp-active > #js-end,
body.makao-mp-active > .vegeredmeny:not(.makao-mp-native-final),
body.makao-mp-active #js-end .js_new_game {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.makao-mp-active #makao-mp-root .makao-mp-native-final {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}


/* === Multiplayer restart host button visibility hardening === */
body.makao-mp-active #makao-mp-root .makao-mp-native-final #mp-final-new-game {
  display: inline-block !important;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
}
body.makao-mp-active:not(.makao-mp-host) #makao-mp-root .makao-mp-native-final #mp-final-new-game {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.makao-mp-active #js-end,
body.makao-mp-active #js-end .vegeredmeny-uj-jatek-button,
body.makao-mp-active .vegeredmeny:not(.makao-mp-native-final) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
