/* =========================================================================
   Hafenmarkt (#shop-panel.mk) – gleiche Sprache wie die Kapitänskajüte:
   Nachtmeer, Messing-Haarlinien, Laternenlicht für Preise und Kaufknöpfe.
   Waren als Zeilen wie im Kontorbuch, nur Designs als Bildraster.
   Token (--abyss, --lantern …) kommen von #hub-screen.quarters.
   ========================================================================= */
#shop-panel.mk, #auction-hub-panel.mk, #trade-hub-panel.mk {
  background: rgba(3, 8, 14, 0.78);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-family: var(--serif);
  color: var(--bone);
}
#shop-panel.mk.hidden, .mk-solo.hidden { display: none !important; }
/* Im Spiel (client/shop.js): Farben/Schriften der Kajüte selbst mitbringen */
#game-screen #shop-panel.mk {
  --abyss: #061019; --tide: #0c1f2b; --storm: #263844; --brass: #b8893f; --lantern: #f0b85a;
  --bone: #ebe1cc; --spray: #93b3b6; --hair: rgba(184, 137, 63, 0.28);
  --serif: 'Crimson Pro', Georgia, serif; --title: 'Cinzel', 'Crimson Pro', Georgia, serif;
  z-index: 60; pointer-events: auto;
}
/* Auktionshaus / Spielermarkt: eigenes Fenster ohne Rubrikleiste */
#auction-hub-panel, #trade-hub-panel { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; }
.mk-solo .mk-sheet { width: min(980px, calc(100vw - 48px)); }
.mk-solo .mk-content { padding: 26px 34px 60px; }
.mk-solo .mk-solo-lede { margin: 0 0 16px; font-size: 17px; color: var(--spray); max-width: 64ch; }
.mk h2, .mk h3, .mk h4, .mk p, .mk figure, .mk dl, .mk dd { margin: 0; }

.mk-sheet {
  position: relative;
  width: min(1240px, calc(100vw - 48px));
  height: min(880px, calc(100dvh - 48px));
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--abyss);
  border: 1px solid var(--hair); border-top: 2px solid var(--brass);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* ---------- Kopf ---------- */
.mk-head { display: flex; align-items: center; gap: 24px; padding: 18px 20px 18px 30px; border-bottom: 1px solid var(--hair); }
.mk-head h2 { font-family: var(--title); font-weight: 700; font-size: 30px; color: var(--bone); line-height: 1.1; }
.mk-wallet { margin-left: auto; display: flex; gap: 22px; }
.mk-coin { font: 600 19px var(--serif); color: var(--bone); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-coin img { width: 20px; height: 20px; vertical-align: -4px; }
.mk-close {
  width: 44px; height: 44px; border: 1px solid rgba(235, 225, 204, 0.22); border-radius: 4px;
  background: none; color: var(--bone); font-size: 26px; line-height: 1; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.mk-close:hover { border-color: var(--lantern); color: var(--lantern); }

/* ---------- Gerüst: Rubriken links, Waren rechts ---------- */
.mk-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 0; }
.mk-rail { display: flex; flex-direction: column; padding: 18px 0; border-right: 1px solid var(--hair); }
.mk-rail .shop-tab-btn {
  text-align: left; padding: 12px 26px; border: 0; border-left: 2px solid transparent;
  background: none; color: var(--spray); font: 18px var(--serif); cursor: pointer;
  transition: color .2s, background-color .2s, border-color .2s;
}
.mk-rail .shop-tab-btn:hover { color: var(--bone); }
.mk-rail .shop-tab-btn.active { color: var(--bone); border-left-color: var(--lantern); background: rgba(240, 184, 90, 0.07); }
.mk-content { overflow-y: auto; padding: 30px 38px 70px; -webkit-overflow-scrolling: touch; }
.mk-content .hidden, .mk-content .event-off { display: none !important; }

.mk-section-head { margin-bottom: 6px; }
.mk-section-head h3 { font-family: var(--title); font-weight: 700; font-size: 26px; color: var(--bone); }
.mk-section-head p { margin-top: 6px; max-width: 64ch; font-size: 17px; color: var(--spray); }
.mk-head-note { font: italic 16px var(--serif); color: var(--brass); margin-left: 8px; }
section.shop-tab-section + section.shop-tab-section { margin-top: 44px; }

/* ---------- Warenzeile ---------- */
.mk-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 20px;
  padding: 20px 0; border-bottom: 1px solid rgba(147, 179, 182, 0.1);
}
.mk-cannon { grid-template-columns: minmax(0, 1fr) auto; }
.mk-row-icon { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
.mk-row-glyph { display: flex; align-items: center; justify-content: center; font-size: 30px; background: rgba(12, 31, 43, 0.8); }
.mk-row-text h4 { font: 600 21px var(--serif); color: var(--bone); line-height: 1.25; }
.mk-row-text p { margin-top: 3px; font-size: 16px; line-height: 1.5; color: var(--spray); max-width: 60ch; }
.mk-stock { display: inline-block; margin-top: 6px; font: italic 15px var(--serif); color: var(--brass); }
.mk-event-tag { margin-left: 6px; padding: 1px 8px; border: 1px solid rgba(240, 184, 90, 0.5); border-radius: 999px; font: italic 13px var(--serif); color: var(--lantern); vertical-align: 2px; }
.mk-soon { opacity: 0.75; }
.mk .soon-tag { font-size: 15px; color: var(--spray); }

.mk-stats { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-top: 8px; }
.mk-stats dt { font: italic 14px var(--serif); color: var(--spray); }
.mk-stats dd { font: 600 17px var(--serif); color: var(--bone); font-variant-numeric: tabular-nums; }
.mk-elite h4 { color: #dccbff; }

/* ---------- Angebote (Menge + Preis) ---------- */
.mk-offers { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.mk-offer {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 104px; min-height: 58px; padding: 8px 14px;
  border: 1px solid rgba(235, 225, 204, 0.22); border-radius: 4px; background: rgba(12, 31, 43, 0.7);
  color: var(--bone); font-family: var(--serif); cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.mk-offer:hover:not(:disabled) { border-color: var(--lantern); background: rgba(240, 184, 90, 0.1); }
.mk-offer:disabled { opacity: 0.38; cursor: not-allowed; }
.mk-qty { font-family: var(--title); font-weight: 700; font-size: 18px; line-height: 1.1; }
.mk-price { font: 600 16px var(--serif); color: var(--lantern); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-price img { width: 16px; height: 16px; vertical-align: -3px; }
.mk-best { border-color: rgba(240, 184, 90, 0.7); }
.mk-best-tag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  padding: 0 8px; border-radius: 999px; background: var(--lantern); color: #1c1208;
  font: italic 600 12px/18px var(--serif); white-space: nowrap;
}

/* ---------- Freie Menge ---------- */
.mk-custom { display: flex; align-items: stretch; gap: 0; margin-left: 6px; }
.mk-custom-field {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  width: 108px; min-height: 58px; padding: 6px 10px 6px 12px;
  border: 1px solid rgba(235, 225, 204, 0.22); border-right: 0; border-radius: 4px 0 0 4px; background: rgba(6, 16, 25, 0.9);
  cursor: text; transition: border-color .2s;
}
.mk-custom-field:focus-within { border-color: var(--lantern); }
.mk-custom-field span { font: italic 13px var(--serif); color: var(--spray); line-height: 1.1; }
.mk-custom-field input {
  width: 100%; padding: 0; border: 0; background: none; outline: none;
  color: var(--bone); font-family: var(--title); font-weight: 700; font-size: 18px; line-height: 1.2;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.mk-custom-field input::-webkit-outer-spin-button, .mk-custom-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mk-custom-field input::placeholder { color: rgba(147, 179, 182, 0.45); }
.mk-custom-buy { border-radius: 0 4px 4px 0; min-width: 104px; }
.mk-custom-buy .mk-qty { font: 600 17px var(--serif); }
#hub-screen.quarters .mk-custom-field input:focus-visible { outline: none; }
.mk-custom-buy:disabled { opacity: 1; }
.mk-custom-buy:disabled .mk-qty { color: var(--spray); }
.mk-custom-buy:disabled .mk-price { color: var(--spray); }
.mk-custom-buy.mk-poor .mk-price { color: #e0866f; }
.mk-custom-buy:not(:disabled) { border-color: rgba(240, 184, 90, 0.7); }

/* ---------- Elite-Schiff ---------- */
.mk-feature {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 12px;
  margin-bottom: 44px; padding: 10px 34px 10px 10px;
  background: radial-gradient(ellipse at 28% 50%, rgba(240, 184, 90, 0.12), transparent 60%), url('assets/site/quarters-sea.webp') 70% 50% / cover;
  border: 1px solid var(--hair); position: relative; isolation: isolate;
}
.mk-feature::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(6,16,25,0.15), rgba(6,16,25,0.85) 55%); }
.mk-feature-art img { display: block; width: 100%; max-width: 340px; margin: 0 auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(22px 28px 18px rgba(0, 6, 12, 0.65)); }
.mk-kind { font: italic 17px var(--serif); color: var(--spray); }
.mk-feature h3 { font-family: var(--title); font-weight: 700; font-size: 42px; line-height: 1.05; color: var(--bone); }
.mk-feature p { margin-top: 10px; font-size: 17px; color: var(--spray); max-width: 46ch; }
.mk-buy {
  display: inline-flex; align-items: center; gap: 14px; margin-top: 22px; min-height: 52px; padding: 0 26px;
  border: 0; border-radius: 4px; background: var(--lantern); color: #1c1208; font: 600 19px var(--serif); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,220,150,0.6) inset, 0 10px 34px rgba(240,160,60,0.35);
  transition: background-color .2s, box-shadow .2s;
}
.mk-buy strong { font-variant-numeric: tabular-nums; }
.mk-buy img { width: 18px; height: 18px; vertical-align: -3px; }
.mk-buy:hover:not(:disabled) { background: #ffd07a; }
.mk-buy:disabled { background: var(--storm); color: var(--bone); box-shadow: none; cursor: default; }

/* ---------- Designs (Bildraster) ---------- */
.mk-designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 26px 20px; margin-top: 22px; }
.mk-design { position: relative; }
.mk-design img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.mk-design figcaption { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.mk-design strong { font: 600 17px var(--serif); color: var(--bone); line-height: 1.2; }
.mk-design .mk-offer { min-width: 0; min-height: 40px; padding: 4px 12px; }
.mk-owned-tag { font: italic 15px var(--serif); color: var(--brass); white-space: nowrap; }
.mk-ribbon { position: absolute; top: 10px; left: 10px; z-index: 1; padding: 1px 9px; border-radius: 999px; background: rgba(6, 16, 25, 0.85); font: italic 13px var(--serif); color: var(--bone); }
.mk-design.winter img { box-shadow: 0 0 0 1px rgba(170, 225, 255, 0.6), 0 10px 30px rgba(0, 0, 0, 0.5); }
.mk-design.winter .mk-ribbon { border: 1px solid rgba(170, 225, 255, 0.7); color: #dff3ff; }
.mk-design.halloween img { box-shadow: 0 0 0 1px rgba(255, 150, 60, 0.6), 0 10px 30px rgba(0, 0, 0, 0.5); }
.mk-design.halloween .mk-ribbon { border: 1px solid rgba(255, 150, 60, 0.75); color: #ffd9b0; }

/* ---------- Schiffsglanz ---------- */
.mk-glows { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; margin-top: 22px; }
.mk-glow { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 12px 16px; border: 1px solid rgba(147, 179, 182, 0.12); text-align: center; }
.mk-glow.mk-owned { border-color: var(--hair); }
.mk-swatch { width: 76px; height: 76px; border-radius: 50%; }
.mk-glow strong { font: 600 17px var(--serif); color: var(--bone); }
.mk-glow .mk-offer { min-height: 40px; }
.mk-glow-equip { display: flex; gap: 8px; }
.mk .glow-equip-btn {
  min-height: 36px; padding: 0 14px; border: 1px solid rgba(235, 225, 204, 0.22); border-radius: 4px;
  background: none; color: var(--spray); font: 16px var(--serif); cursor: pointer; transition: border-color .2s, color .2s, background-color .2s;
}
.mk .glow-equip-btn:hover { color: var(--bone); border-color: var(--bone); }
.mk .glow-equip-btn.active { color: #1c1208; background: var(--lantern); border-color: var(--lantern); }

/* ---------- Rückmeldung ---------- */
.mk-toast {
  position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 12px);
  width: max-content; max-width: calc(100% - 32px); padding: 12px 22px; border: 1px solid var(--lantern); border-radius: 4px;
  background: rgba(12, 31, 43, 0.96); color: var(--bone); font-size: 17px; text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.mk-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  .mk-sheet { width: 100vw; height: 100dvh; border: 0; border-top: 2px solid var(--brass); }
  .mk-head { gap: 12px; padding: 12px 12px 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .mk-head h2 { font-size: 22px; }
  .mk-wallet { gap: 12px; }
  .mk-coin { font-size: 16px; }
  .mk-close { width: 40px; height: 40px; }
  .mk-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .mk-rail { flex-direction: row; overflow-x: auto; padding: 0 8px; border-right: 0; border-bottom: 1px solid var(--hair); scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .mk-rail::-webkit-scrollbar { display: none; }
  .mk-rail .shop-tab-btn { flex: 0 0 auto; padding: 12px 12px; border-left: 0; border-bottom: 2px solid transparent; font-size: 17px; }
  .mk-rail .shop-tab-btn.active { border-bottom-color: var(--lantern); background: none; }
  .mk-content { padding: 22px 16px calc(70px + env(safe-area-inset-bottom, 0px)); }
  .mk-row { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
  .mk-cannon { grid-template-columns: 1fr; }
  .mk-row-icon { width: 44px; height: 44px; }
  .mk-row .mk-offers { grid-column: 1 / -1; justify-content: flex-start; }
  .mk-offer { min-width: 0; flex: 1 1 88px; }
  .mk-custom { flex: 1 1 100%; margin-left: 0; }
  .mk-custom-field { flex: 1 1 auto; width: auto; }
  .mk-custom-buy { flex: 0 0 132px; }
  .mk-feature { grid-template-columns: 1fr; padding: 0 18px 24px; text-align: left; }
  .mk-feature::before { background: linear-gradient(180deg, rgba(6,16,25,0.1), rgba(6,16,25,0.9) 55%); }
  .mk-feature-art img { max-width: 240px; }
  .mk-feature h3 { font-size: 32px; }
  .mk-designs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
  .mk-design figcaption { flex-direction: column; align-items: stretch; }
  .mk-glows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .mk-toast { transition: none; } }
