* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #1b2a22; color: #f1f5ef;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* bara de derulare in stilul jocului (Chrome/Edge/Safari + Firefox) */
* { scrollbar-width: thin; scrollbar-color: #4f7a5e transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; margin: 14px 0; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(#5f9a72, #3f6b4f); border-radius: 8px;
  border: 2px solid rgba(15, 24, 19, 0.92);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(#ffd34e, #d9a92a); }
::-webkit-scrollbar-corner { background: transparent; }

/* selectorul de limba: in colt, doar in meniu (nu si in timpul jocului) */
#langSelect {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  padding: 7px 30px 7px 12px; border-radius: 10px; cursor: pointer;
  background: rgba(15, 24, 19, 0.9) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23ffd34e'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: #f1f5ef; border: 2px solid #34503f; font-size: 14px; font-weight: 600;
  appearance: none; -webkit-appearance: none; outline: none;
}
#langSelect:hover, #langSelect:focus { border-color: #7fd6a4; }
#langSelect option { background: #0f1813; color: #f1f5ef; }
#hud:not(.hidden) ~ #langSelect { display: none; }

/* conexiunea pierduta: vizibil si in meniu, si in joc */
#netStatus {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: rgba(15, 24, 19, 0.95); color: #ffd34e; border: 2px solid #ffd34e66;
  padding: 8px 16px 8px 36px; border-radius: 12px; font-weight: 700; font-size: 14px;
}
#netStatus::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border: 2px solid #ffd34e; border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

a { color: #7fd6a4; }

/* --- ferestre: meniu, logare, rezultate --- */
.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto;
  background: rgba(15, 24, 19, 0.92); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 18px;
  padding: 28px 24px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
#auth { z-index: 10; }
#dupe { z-index: 11; }
.panel h1 { font-size: 44px; letter-spacing: -1px; }
.panel h1 span { color: #ffd34e; }
.panel .tag { opacity: 0.75; margin: 4px 0 18px; }
/* explicatia jocului, pentru cine intra prima data */
.panel .intro {
  margin: -8px 0 16px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 211, 78, 0.08); border: 1px solid rgba(255, 211, 78, 0.25);
  font-size: 13.5px; line-height: 1.45; text-align: left;
}
.panel input {
  width: 100%; padding: 13px 16px; font-size: 17px; border-radius: 12px; margin-bottom: 8px;
  border: 2px solid #34503f; background: #0f1813; color: #fff; outline: none; text-align: center;
  user-select: text; -webkit-user-select: text;
}
.panel input:focus { border-color: #7fd6a4; }
button.primary {
  width: 100%; margin-top: 6px; padding: 14px; font-size: 19px; font-weight: 800;
  border: 0; border-radius: 12px; cursor: pointer;
  background: #ffd34e; color: #1b2a22;
}
button.primary:hover { filter: brightness(1.08); }
button.secondary {
  width: 100%; margin-top: 8px; padding: 10px; font-size: 15px; font-weight: 700;
  border: 2px solid #34503f; border-radius: 12px; cursor: pointer; background: transparent; color: #f1f5ef;
}
button.secondary:hover { border-color: #7fd6a4; }

.close {
  position: absolute; top: 10px; right: 14px; background: none; border: 0; color: #fff;
  font-size: 28px; cursor: pointer; opacity: 0.6;
}
.close:hover { opacity: 1; }

/* --- logare --- */
#googleBtn { display: flex; justify-content: center; min-height: 44px; margin-bottom: 8px; }
.social {
  width: 300px; max-width: 100%; height: 44px; border-radius: 22px; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.social.google { background: #fff; color: #222; }
.social.google b { color: #4285f4; font-size: 18px; }
.social.apple { background: #000; color: #fff; border: 1px solid #444; margin-bottom: 4px; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 12px; opacity: 0.6; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.2); }
.switch { margin-top: 10px; font-size: 14px; }
#authMsg { min-height: 20px; margin-top: 8px; font-size: 14px; }
#authMsg.err { color: #ff8a7a; }
.guest { display: inline-block; margin-top: 10px; color: #c8d3cc; font-size: 15px; }

/* --- meniu --- */
#profileLine { margin: -6px 0 14px; font-size: 14px; }
#profileLine a { margin-left: 6px; }
#gearBox { display: flex; align-items: center; gap: 12px; margin: 2px 0 8px; }
#gearPreview { position: relative; cursor: pointer; width: 96px; height: 96px; flex: none; background: #0f1813; border-radius: 14px; border: 2px solid #34503f; }
#gearPreview .dice {
  position: absolute; right: -8px; bottom: -8px; width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 2px solid #34503f; background: #1b2a22; font-size: 17px; line-height: 1; cursor: pointer;
}
#gearPreview .dice:hover { border-color: #ffd34e; }
#gearPreview .dice.roll { animation: diceRoll 0.4s; }
@keyframes diceRoll { from { transform: rotate(0); } to { transform: rotate(360deg); } }
#gearBox .secondary { margin-top: 0; }

/* --- camere --- */
#roomBox { margin: 4px 0 6px; text-align: left; }
#roomBox .label { font-size: 12px; opacity: 0.7; margin-bottom: 4px; }
#roomList { display: flex; flex-direction: column; gap: 4px; }
.room {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 8px 12px; border-radius: 10px; border: 2px solid #34503f; background: #0f1813;
  color: #f1f5ef; font-size: 13px; cursor: pointer; text-align: left;
}
.room small { opacity: 0.5; }
.room.on { border-color: #ffd34e; background: #26301a; }
.room:disabled { opacity: 0.45; cursor: default; }

/* --- culori --- */
.colorPanel { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.colorPanel .label { font-size: 13px; font-weight: 700; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 420px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 3px solid rgba(255,255,255,0.15);
}
.swatch.on { border-color: #ffd34e; transform: scale(1.12); }
.swatch.random { background: conic-gradient(#f28b9b, #f6d76b, #8fd1a8, #9fb8ff, #d9a0f0, #f28b9b); }

/* --- magazin --- */
.panel.wide { width: min(640px, calc(100% - 32px)); z-index: 5; }
#shop h2 { margin-bottom: 2px; }
#shopCoins { color: #ffd34e; font-weight: 800; margin-bottom: 12px; }
#shopTabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
#shopTabs button {
  padding: 8px 14px; border-radius: 10px; border: 2px solid #34503f; background: transparent;
  color: #f1f5ef; font-weight: 700; cursor: pointer;
}
#shopTabs button.on { background: #34503f; border-color: #7fd6a4; }
#shopGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
#shopGrid.single { display: block; }
.card {
  background: #0f1813; border: 2px solid #34503f; border-radius: 14px; padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.card.on { border-color: #ffd34e !important; background: #26301a; }
.card .name { font-weight: 700; font-size: 13px; margin-top: 4px; }
.card .rarity { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .stats, .card .frag { font-size: 11px; opacity: 0.85; }
.card .frag { color: #ffd34e; }
.card .none { font-size: 38px; line-height: 60px; opacity: 0.4; }
.card button {
  margin-top: 6px; width: 100%; padding: 6px; border-radius: 8px; border: 0; cursor: pointer;
  font-weight: 800; background: #34503f; color: #fff;
}
.card button.buy { background: #ffd34e; color: #1b2a22; }
.card button:disabled { opacity: 0.5; cursor: default; }
.card button.gift:disabled { opacity: 1; background: rgba(255, 122, 184, 0.18); color: #ff9fcb; font-size: 11px; }
#shopMsg { min-height: 20px; margin-top: 10px; font-weight: 700; color: #7fd6a4; }
#shopMsg.err { color: #ff8a7a; }
.hint { font-size: 12px; opacity: 0.6; margin-top: 6px; }

.help { list-style: none; margin-top: 16px; text-align: left; font-size: 13px; line-height: 1.4; opacity: 0.85; }
.help li { margin: 4px 0; padding: 2px 0 2px 12px; border-left: 2px solid #34503f; }
.s1 { color: #ffd34e; } .s3 { color: #5ee0ff; } .s6 { color: #ff9a3c; } .s10 { color: #ff6bd6; }

/* --- HUD --- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#topbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center;
}
#score, #timer {
  background: rgba(0,0,0,0.4); padding: 6px 14px; border-radius: 10px;
  font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums;
}
#score { color: #ffd34e; }
#score::before { content: "★ "; }

#leaderboard {
  position: absolute; top: 12px; right: 12px; min-width: 150px;
  background: rgba(0,0,0,0.35); border-radius: 10px; padding: 8px 12px; font-size: 13px;
}
#leaderboard div { display: flex; justify-content: space-between; gap: 12px; }
#leaderboard .me { color: #ffd34e; font-weight: 700; }

#buffs {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; font-size: 13px; font-weight: 700;
}
#buffs span { background: rgba(0,0,0,0.45); padding: 4px 10px; border-radius: 8px; color: #ffd34e; }
#topLeft { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; align-items: center; }
#players {
  background: rgba(0,0,0,0.4); padding: 5px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 700;
}
#exitBtn {
  pointer-events: auto; cursor: pointer;
  background: rgba(0,0,0,0.5); color: #f1f5ef; border: 2px solid rgba(255,255,255,0.15);
  padding: 4px 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
}
#exitBtn:hover { border-color: #ffd34e; color: #ffd34e; }
#buffs { flex-wrap: wrap; justify-content: center; width: calc(100% - 32px); }

#feed { position: absolute; top: 48px; left: 12px; font-size: 13px; max-width: 45%; }
#feed div {
  background: rgba(0,0,0,0.4); padding: 4px 10px; border-radius: 8px; margin-bottom: 4px;
  animation: fade 5s forwards;
}
#feed .miss { color: #ff8a7a; }
#feed .gift { color: #ffd34e; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }


#center {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%);
  font-size: 24px; font-weight: 800; text-align: center; text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  width: calc(100% - 32px);
}
#center.bad { color: #ff8a7a; }

#sprintBtn {
  display: none; position: absolute; right: 24px; bottom: 60px;
  width: 84px; height: 84px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.4);
  background: rgba(255,211,78,0.25); color: #fff; font-weight: 800; font-size: 13px;
  pointer-events: auto;
}
#sprintBtn.on { background: rgba(255,211,78,0.6); }
body.touch #sprintBtn { display: block; }
/* lovitura (telefon): deasupra sprintului, ca degetul sa ajunga usor de la unul la altul */
#hitBtn {
  display: none; position: absolute; right: 34px; bottom: 160px;
  width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.4);
  background: rgba(232,72,74,0.3); color: #fff; font-weight: 800; font-size: 12px;
  pointer-events: auto;
}
#hitBtn.on { background: rgba(232,72,74,0.65); }
body.touch #hitBtn { display: block; }

/* --- rezultate si premii --- */
#results h2 { margin-bottom: 14px; }
#results table { width: 100%; border-collapse: collapse; font-size: 15px; }
#results td { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.07); }
#results td:last-child, #results td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
#results tr:first-child td { color: #ffd34e; font-weight: 800; }
#nextRound { margin-top: 10px; opacity: 0.7; font-size: 14px; }

#caughtLook { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; }
#caughtLook .col { display: flex; flex-direction: column; gap: 8px; flex: 1; }
#caughtPreview { width: 96px; height: 96px; flex: none; background: #0f1813; border-radius: 14px; border: 2px solid #34503f; }
#caughtBack:disabled { opacity: 0.55; cursor: default; }
#loot { margin: 16px 0 6px; }
#lootTitle { font-weight: 700; margin-bottom: 8px; }
#giftRow { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.giftBox {
  width: 86px; height: 112px; box-sizing: border-box; padding: 6px 4px; border-radius: 14px; cursor: pointer;
  background: #0f1813; border: 2px solid #34503f; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 700; text-align: center;
}
.giftBox canvas { flex: none; }
/* numele obiectului: cel mult doua randuri, fara sa iasa din patrat */
.giftBox .name {
  font-size: 11px; line-height: 1.15; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.giftBox .icon { font-size: 40px; line-height: 1; }
.giftBox.closed:hover { border-color: #ffd34e; }
.giftBox.shake .icon { animation: shake 0.5s; }
.giftBox.open { animation: pop 0.35s; cursor: default; }
.giftBox .sub { font-size: 10px; line-height: 1.1; font-weight: 600; opacity: 0.75; }
@keyframes shake {
  0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); }
  60% { transform: rotate(-10deg); } 80% { transform: rotate(8deg); }
}
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
#lootSummary { margin-top: 10px; font-size: 14px; color: #ffd34e; }
#saveBox { margin-top: 12px; padding: 12px; border-radius: 12px; background: rgba(255,211,78,0.08); border: 1px dashed #ffd34e66; }
#saveBox p { font-size: 13px; margin-bottom: 4px; }

/* ecran ingust (telefon): clasa .narrow o pune client.js dupa latimea efectiva a interfetei,
   pentru ca unele telefoane raporteaza latime de desktop si media query-urile nu s-ar aplica */
.narrow #leaderboard { font-size: 11px; min-width: 110px; top: 56px; }
.narrow #topLeft { flex-direction: column; align-items: flex-start; gap: 6px; }
.narrow #exitBtn, .narrow #players { font-size: 12px; padding: 4px 10px; }
.narrow #score, .narrow #timer { font-size: 17px; padding: 5px 10px; }
.narrow #topbar { gap: 8px; }
.narrow #feed { top: 96px; font-size: 11px; }
.narrow #center { font-size: 18px; }
.narrow #buffs { top: 100px; font-size: 11px; }
.narrow .panel h1 { font-size: 36px; }
/* loc pentru selectorul de limba deasupra ferestrei */
.narrow .panel { top: calc(50% + 24px); max-height: calc(100% - 80px); }

/* stratul de interfata: --z > 1 il mareste pe telefoanele care afiseaza pagina ca pe desktop */
:root { --z: 1; }
#ui {
  position: fixed; left: 0; top: 0;
  width: calc(100% / var(--z)); height: calc(100% / var(--z));
  transform: scale(var(--z)); transform-origin: 0 0;
  pointer-events: none;
}
#ui > * { pointer-events: auto; }
#ui > #hud { pointer-events: none; }
