* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Montserrat, system-ui, sans-serif;
  font-weight: 700;
  color: #fff;
  background: #46178f;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .4s;
}
/* Kahoot uslubidagi fon shakllari */
body::before, body::after {
  content: ''; position: fixed; z-index: -1; background: rgba(255, 255, 255, .06);
}
body::before { width: 60vmax; height: 60vmax; left: -20vmax; bottom: -30vmax; border-radius: 50%; }
body::after { width: 45vmax; height: 45vmax; right: -12vmax; top: -18vmax; transform: rotate(45deg); }

.logo { font-weight: 900; font-size: clamp(2.2rem, 7vw, 4.5rem); text-align: center; letter-spacing: -1px; margin: .3em 0; text-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.logo.small { font-size: clamp(1.2rem, 2.4vw, 2rem); margin: 0; text-align: left; }

.card { background: #fff; color: #333; border-radius: 8px; padding: 24px; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.btn {
  background: #333; color: #fff; border: 0; border-radius: 6px; padding: 14px 28px;
  font: inherit; font-size: 1.2rem; cursor: pointer; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .35);
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.big { font-size: clamp(1.4rem, 3vw, 2.2rem); padding: .6em 2em; }
.btn.block { width: 100%; margin-top: 12px; }
.btn.ghost { background: rgba(255, 255, 255, .15); font-size: 1rem; padding: 10px 18px; }
.btn:focus-visible, .door:focus-visible, input:focus-visible { outline: 4px solid #ffd84d; outline-offset: 2px; }

input.pin {
  width: 100%; font: inherit; font-size: 1.5rem; text-align: center; padding: 12px;
  border: 3px solid #ccc; border-radius: 6px; color: #333;
}
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; text-align: center; }
.joinform { width: min(100%, 340px); }
.err { color: #e21b3c; min-height: 1.2em; margin: 10px 0 0; }

/* ---------- Eshiklar ---------- */
.doors { display: grid; gap: 14px; }
.door {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3em;
  font: inherit; color: #fff; text-align: center; padding: 1.4em .4em .8em;
  background: linear-gradient(#a8702f, #7a4a1c);
  border: 6px solid #4d2c0c; border-radius: 48% 48% 8px 8px / 26% 26% 8px 8px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .08), 0 6px 0 rgba(0, 0, 0, .3);
}
.door::after { /* tutqich */
  content: ''; position: absolute; right: 12%; top: 55%; width: .7em; height: .7em; border-radius: 50%; background: #ffd84d;
}
.door .num { font-size: 2.6em; font-weight: 900; line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.door .pts { background: rgba(0, 0, 0, .35); padding: .15em .7em; border-radius: 99px; }
.door .lock, .door .gem { font-size: 1.8em; line-height: 1; }
.door .who { background: var(--g); padding: .15em .7em; border-radius: 6px; }
.door .tries { font-size: .85em; opacity: .9; }
.lvl { font-size: .8em; padding: .1em .6em; border-radius: 4px; }
.lvl.easy { background: #26890c; }
.lvl.medium { background: #d89e00; }
.lvl.hard { background: #e21b3c; }

.door.busy { border-color: var(--g); animation: pulse 1.4s ease-in-out infinite; }
.door.open { background: radial-gradient(circle at 50% 55%, #fff3b0, #ffc400 25%, #8a5a00 55%, #2a1904 80%); border-color: var(--g); }
.door.open::after { display: none; }
button.door { cursor: pointer; }
button.door:hover { filter: brightness(1.15); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--g), 0 0 40px var(--g); } }

/* ---------- O‘qituvchi ekrani (TV) ---------- */
.host { padding: 2vh 2vw; height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: center; }
.joinbox { background: #fff; color: #333; border-radius: 8px; padding: .5em 1.2em; font-size: clamp(1rem, 2.2vw, 1.8rem); }
.joinbox b { color: #46178f; }
.codes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2vw; margin: 3vh 0; }
.codecard { background: #fff; color: #333; border-radius: 10px; overflow: hidden; text-align: center; box-shadow: 0 6px 0 rgba(0, 0, 0, .2); }
.codecard .gname { background: var(--g); color: #fff; font-size: clamp(1.2rem, 2.6vw, 2.2rem); padding: .4em; }
.codecard .label { margin-top: .8em; color: #666; font-size: clamp(.9rem, 1.5vw, 1.3rem); }
.codecard .code { font-size: clamp(2.5rem, 7vw, 6rem); font-weight: 900; letter-spacing: .05em; color: #333; }
.codecard .status { padding: .6em; font-size: clamp(1rem, 1.8vw, 1.5rem); }
.codecard.joined .status { background: #e6f6e2; color: #26890c; }
.lobbyfoot { display: flex; justify-content: center; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 1em; margin-bottom: 2vh; }
.turn { font-size: clamp(1.1rem, 2.4vw, 2rem); background: rgba(0, 0, 0, .25); padding: .3em 1em; border-radius: 99px; }
.turn span { padding: 0 .3em; border-radius: 4px; }
.board { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(220px, 22vw); gap: 2vw; }
.host .doors { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); height: 100%; font-size: clamp(1rem, 2.9vh, 2.2rem); }
.scores { display: flex; flex-direction: column; gap: 1.5vh; }
.score { background: #fff; color: #333; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.score .gname { background: var(--g); color: #fff; padding: .4em .8em; font-size: clamp(1rem, 2vw, 1.6rem); }
.score .pts { font-size: clamp(2rem, 5vw, 4rem); font-weight: 900; text-align: center; }
.score .st { text-align: center; color: #666; padding-bottom: .6em; font-size: clamp(.8rem, 1.2vw, 1.1rem); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 2vw; margin-top: 4vh; }
.step { width: min(26vw, 320px); text-align: center; }
.step .block { background: var(--g); border-radius: 8px 8px 0 0; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 1em; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .2); }
.step .medal { font-size: clamp(3rem, 8vw, 6rem); }
.step .gname { font-size: clamp(1.2rem, 2.6vw, 2.2rem); }
.step .pts { font-size: clamp(1.4rem, 3.4vw, 3rem); font-weight: 900; }

/* ---------- Telefon ---------- */
.phone { padding: 16px; max-width: 520px; margin: 0 auto; }
.ptop { display: flex; justify-content: space-between; align-items: center; background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.ptop .myscore { font-size: 1.3rem; }
.phone h2 { text-align: center; margin: .4em 0 .8em; }
.phone .doors { grid-template-columns: repeat(3, 1fr); gap: 10px; font-size: .8rem; }
.phone .door { aspect-ratio: 3 / 4.3; }
.phone .doors.small { opacity: .85; }
.qcard .qhead { display: flex; justify-content: space-between; align-items: center; color: #666; }
.qtext { font-size: 1.5rem; line-height: 1.35; color: #222; margin: 18px 0; }
.hint { color: #666; font-weight: 600; font-size: .9rem; margin: 14px 0 0; }
.big-msg { font-size: 1.4rem; line-height: 1.4; text-align: center; background: rgba(0, 0, 0, .2); border-radius: 8px; padding: 18px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 150%); padding: 14px 22px; border-radius: 8px;
  font-size: 1.3rem; color: #fff; transition: transform .25s; z-index: 10; max-width: 92vw; text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
#toast.ok { background: #26890c; }
#toast.bad { background: #e21b3c; }

@media (max-width: 800px) {
  .host { height: auto; min-height: 100vh; }
  .codes { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .host .doors { height: auto; grid-template-columns: repeat(3, 1fr); grid-template-rows: none; }
  .host .door { aspect-ratio: 3 / 4; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
