@font-face {
  font-family: PTSans;
  src: url('/fonts/PTSans-Regular.woff') format('woff'),
       url('/fonts/PTSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --guest: #8bc34a;
  --guest-hover: #a4d070;
  --cyan: #26c6da;
  --cyan-hover: #52d1e1;
  --orange: #f7941d;
  --panel: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: PTSans, "Segoe UI", sans-serif;
  background: #1a0f14;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game, #fx {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}
#fx { pointer-events: none; z-index: 5; }
#game { z-index: 1; background: #140a10; }

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 80, 120, 0.22), transparent 55%),
    url('/images/bg-event-pattern-valday2025.png') center/cover;
}
.hidden { display: none !important; }

.guestBadge {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 12px 8px 8px;
  backdrop-filter: blur(8px);
  z-index: 2;
}
.guestBadge img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,.35);
  object-fit: cover;
}
.guestName { font-size: 14px; font-weight: 700; }
.guestLvl {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #ffd166;
  margin-top: 2px;
}
.guestLvl img { width: 14px; height: 14px; border: none; }

.homeCenter {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: min(400px, 92vw);
  text-align: center;
  z-index: 2;
}

.mm-logo {
  width: min(360px, 88vw);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.45));
  display: block;
  margin: 0 auto;
}
.mm-event-cont, .seasonTag {
  margin: 2px 0 12px;
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 6px rgba(0,0,0,.55);
}

.skinRow, .mm-skin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 16px;
  min-height: 96px;
}
.skinPreview {
  width: 92px;
  height: 92px;
  min-width: 92px;
  min-height: 92px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.9);
  background-color: #1a1016;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 3px rgba(245, 197, 66, .45), 0 10px 24px rgba(0,0,0,.45);
}
.skinNav {
  width: 52px;
  height: 44px;
  min-width: 48px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.skinNav svg { width: 48px; height: 36px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
#skinPrev svg { transform: scaleX(-1); }
.skinNav:hover svg path,
.skinNav:hover svg circle { stroke: #ffe08a; }

.paramsRow, .mm-params {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}
#nameInput, #modeSelect {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  height: 46px;
}
#nameInput {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 14px;
  border-radius: 6px;
  background: #fff !important;
  color: #222 !important;
}
#modeSelect {
  flex: 0 0 118px;
  width: 118px;
  padding: 0 10px;
  border-radius: 6px;
  background: #26c6da !important;
  color: #fff !important;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  text-align: center;
}

.actionsRow, .mm-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
}
.btnGuest, .btnLogin, .btnSettings {
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  height: 48px;
  padding: 0 12px;
  transition: background-color .2s ease;
  color: #fff !important;
}
.btnGuest {
  flex: 1.45 1 auto;
  background: #8bc34a !important;
}
.btnGuest:hover { background: #a4d070 !important; }
.btnGuest span { color: #fff !important; }
.btnLogin {
  flex: 1 1 auto;
  background: #26c6da !important;
  opacity: .75;
  cursor: not-allowed;
}
.btnGuest:disabled { opacity: .65; cursor: default; }

.btnSettings {
  margin-top: 10px;
  width: 100%;
  height: 40px;
  background: #26c6da !important;
  font-size: 14px;
}
.btnSettings:hover { background: #52d1e1 !important; }

.hint, .mm-advice {
  margin-top: 12px;
  font-size: 13px;
  color: rgba(255,255,255,.85);
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
  min-height: 20px;
}
.homeStatus {
  min-height: 18px;
  margin-top: 8px;
  font-size: 13px;
  color: #7fe0ff;
}

.sideCopy {
  position: absolute;
  left: 16px;
  bottom: max(52px, calc(env(safe-area-inset-bottom) + 44px));
  width: min(280px, 40vw);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(8px);
  z-index: 2;
}
.sideCopy h1 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #ffd9a8;
}
.sideCopy p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255,255,255,.82);
}

.mm-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: rgba(0,0,0,.55);
  font-size: 12px;
  color: rgba(255,255,255,.75);
}
.mm-footer .copy {
  margin-left: 12px;
  color: rgba(255,255,255,.45);
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}
.scoreBox, .leaderboard {
  position: absolute;
  right: 12px;
  background: rgba(0,0,0,.55);
  border-radius: 8px;
  padding: 8px 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.08);
}
.scoreBox {
  top: max(12px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.scoreLabel { font-size: 12px; color: #bbb; }
#scoreValue { font-size: 22px; color: #fff; font-weight: 700; }
.leaderboard { top: max(58px, calc(env(safe-area-inset-top) + 46px)); width: 168px; }
.leaderboardTitle {
  font-size: 12px;
  color: var(--orange);
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.leaderboard ol {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 12px;
  line-height: 1.55;
  color: #eee;
}
.boostHint {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.4);
  padding: 6px 12px;
  border-radius: 16px;
}

.buffHud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px 8px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  min-width: 148px;
  max-width: 200px;
}
.buffHud canvas {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
}
.buffMeta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
#buffLabel { font-size: 13px; letter-spacing: 0.5px; color: #7fe0ff; }
#buffTimer { font-size: 18px; color: #fff; }
.buffBar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.15);
  overflow: hidden;
}
.buffBar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #26c6da, #8bc34a);
  transform-origin: left center;
}

.storeRow, .mm-merchant-cont {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.storeRow img { height: 34px; opacity: 0.92; }

.storeMini {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.storeMini img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
}

/* —— Results / Congrats (مطابق Wormate) —— */
.results-view {
  background: transparent !important;
  z-index: 50;
}
#congrats-bg {
  background: rgba(0, 0, 0, 0.55);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#congrats-wrap {
  position: absolute;
  width: 100%;
  height: 100%;
}
#congrats {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 92vw);
  height: min(360px, 78vh);
  background-color: #fff;
  box-shadow: 0 0 200px 80px rgba(34, 34, 34, 0.75);
  border-radius: 4px;
  color: #333;
  overflow: hidden;
}
#final-caption {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: #f7941d;
  color: #fff;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: 3px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}
#final-message {
  position: absolute;
  top: 75px;
  left: 0;
  right: 0;
  height: 25px;
  line-height: 25px;
  text-align: center;
  font-size: 18px;
  color: #444;
}
#final-score {
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: #2d92bd;
}
#final-place {
  position: absolute;
  top: 140px;
  left: 0;
  right: 0;
  height: 50px;
  line-height: 50px;
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  color: #f7941d;
}
#final-board {
  position: absolute;
  top: 190px;
  left: 12px;
  right: 12px;
  height: 70px;
  text-align: center;
  font-size: 14px;
  color: #555;
  line-height: 1.4;
  overflow: hidden;
}
#congrats .controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
}
#respawnBtn {
  position: absolute;
  top: 10px;
  left: 15px;
  right: 15px;
  background-color: #8bc34a;
  color: #fff;
  border: none;
  height: 50px;
  line-height: 50px;
  font-size: 24px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
}
#respawnBtn:hover { background-color: #a4d070; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 6, 10, 0.82);
  font-size: 18px;
}
.loading img, .mm-loading-logo { width: min(320px, 80vw); }

@media (max-width: 720px) {
  .sideCopy { display: none; }
  .homeCenter { top: 48%; }
  .mm-footer .copy { display: none; }
}

/* —— Mute —— */
.muteBtn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: rgba(0,0,0,.45);
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.muteBtn:hover { background: rgba(0,0,0,.65); }

.btnSettingsAlt { margin-top: 6px; background: rgba(255,255,255,.12) !important; }

/* —— Team HUD —— */
.teamHud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
}
.teamChip {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  background: rgba(0,0,0,.55);
  border: 2px solid transparent;
}
.teamChip span { opacity: .85; letter-spacing: .5px; }
.teamChip b { font-size: 18px; }
.teamRed { border-color: #f24954; color: #ff8a90; }
.teamBlue { border-color: #497ef2; color: #8eb6ff; }
.myTeamBadge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.12);
}

/* —— Wear Store —— */
.wearModal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 12px 24px;
  overflow: auto;
}
.wearCard {
  width: min(560px, 96vw);
  background: linear-gradient(180deg, #1a2740, #0d1524);
  border: 1px solid rgba(56, 189, 248, .25);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  padding: 14px;
  color: #fff;
}
.wearHead {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.wearLogo { width: 36px; height: 36px; border-radius: 8px; }
.wearClose {
  margin-left: auto;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}
.wearTabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.wearTab {
  border: none;
  background: rgba(255,255,255,.08);
  color: #ddd;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}
.wearTab.active {
  background: #26c6da;
  color: #fff;
}
.wearPreviewRow {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  background: rgba(0,0,0,.35);
  border-radius: 12px;
  padding: 10px;
}
#wearPreviewCanvas {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #120a12;
  border: 3px solid rgba(255,255,255,.25);
}
.wearPreviewMeta { flex: 1; }
#wearItemName { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
#wearItemPrice { color: #fcd34d; margin-bottom: 10px; font-size: 13px; }
#wearApplyBtn { width: 100%; height: 42px; }
.wearGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: min(42vh, 320px);
  overflow: auto;
  padding: 4px;
}
.wearCell {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  cursor: pointer;
  padding: 4px;
  position: relative;
}
.wearCell canvas { width: 100%; height: 100%; display: block; }
.wearCell.selected { border-color: #fcd34d; box-shadow: 0 0 0 2px rgba(252,211,77,.35); }
.wearCell .priceTag {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  background: rgba(0,0,0,.7);
  padding: 1px 4px;
  border-radius: 4px;
  color: #fcd34d;
}
.wearCell.guest .priceTag { color: #8bc34a; }

@media (max-width: 720px) {
  .sideCopy { display: none; }
  /* زر Wear على الموبايل من الهوم سنتر */
}
.wearMobileBtn { display: none; margin-top: 10px; width: 100%; }
@media (max-width: 720px) {
  .wearMobileBtn { display: block; }
}
