/* ═══════════════════════════════════════════════════════════
   QUIZ GAME — Global Styles
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #0d0f1a;
  --bg2:       #161928;
  --bg3:       #1e2236;
  --card:      #1a1d2e;
  --border:    #2a2f4a;
  --accent:    #6c63ff;
  --accent2:   #ff6b6b;
  --green:     #4ade80;
  --red:       #f87171;
  --yellow:    #fbbf24;
  --text:      #e8eaf0;
  --text2:     #8890b0;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --transition: .2s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Corner Trigger ──────────────────────────────────────── */
#corner-trigger {
  position: fixed;
  top: 0; right: 0;
  width: 60px; height: 60px;
  z-index: 9999;
  cursor: pointer;
}
#corner-trigger::after {
  content: '⚙';
  position: absolute;
  top: 8px; right: 10px;
  font-size: 20px;
  opacity: 0;
  transition: opacity var(--transition);
  color: var(--text2);
}
#corner-trigger:hover::after { opacity: 0.5; }

/* ── Modals ──────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(380px, 92vw);
  box-shadow: var(--shadow);
  position: relative;
}
.modal-box h2 { margin-bottom: 1.2rem; font-size: 1.3rem; }
.modal-box input[type="password"],
.modal-box input[type="text"] {
  width: 100%;
  padding: .7rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border var(--transition);
}
.modal-box input:focus { border-color: var(--accent); }
.modal-actions {
  display: flex; gap: .7rem;
  margin-top: 1rem;
  justify-content: flex-end;
}
.close-btn {
  position: absolute; top: .7rem; right: .8rem;
  background: none; border: none;
  color: var(--text2); cursor: pointer; font-size: 1.1rem;
}
.close-btn:hover { color: var(--text); }
.role-btn {
  display: block; width: 100%;
  margin-bottom: .7rem;
  padding: .85rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2); color: var(--text);
  font-size: 1rem; cursor: pointer; text-align: left;
  transition: background var(--transition), border var(--transition);
}
.role-btn:hover { background: var(--bg3); border-color: var(--accent); }
.error { color: var(--red); font-size: .88rem; margin-top: .5rem; }

/* ── Buttons ─────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; transition: opacity var(--transition), transform var(--transition); }
button:active { transform: scale(.97); }

.btn-primary {
  padding: .65rem 1.4rem; border-radius: 8px;
  border: none; background: var(--accent); color: #fff;
  font-size: .95rem; font-weight: 600;
}
.btn-primary:hover { opacity: .88; }
.btn-primary.big { padding: .9rem 2rem; font-size: 1.1rem; }

.btn-secondary {
  padding: .65rem 1.4rem; border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text2); font-size: .95rem;
}
.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

.btn-warning {
  padding: .75rem 1.4rem; border-radius: 8px;
  border: none; background: var(--yellow); color: #111;
  font-size: .95rem; font-weight: 600;
}
.btn-warning:hover:not(:disabled) { opacity: .88; }
.btn-warning:disabled { opacity: .35; cursor: not-allowed; }

.btn-accent {
  padding: .75rem 1.4rem; border-radius: 8px;
  border: none; background: #ec4899; color: #fff;
  font-size: .95rem; font-weight: 600;
}
.btn-accent:hover:not(:disabled) { opacity: .88; }
.btn-accent:disabled { opacity: .35; cursor: not-allowed; }

.btn-danger {
  padding: .75rem 1.4rem; border-radius: 8px;
  border: none; background: var(--red); color: #fff;
  font-size: .95rem; font-weight: 600;
}
.btn-danger:hover { opacity: .88; }
.wide { width: 100%; }

/* ── Views ───────────────────────────────────────────────── */
.view { min-height: 100vh; padding: 2rem 1.5rem; }

/* ── Landing ─────────────────────────────────────────────── */
.landing-view { display: flex; align-items: center; justify-content: center; }
.landing-content { text-align: center; max-width: 460px; }
.landing-content .logo { font-size: 5rem; margin-bottom: 1rem; }
.landing-content h1 {
  font-size: 2.5rem; font-weight: 700; margin-bottom: .8rem;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.landing-content p { color: var(--text2); margin-bottom: 2rem; font-size: 1.05rem; }

/* ── Centered message ────────────────────────────────────── */
.centered-msg {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 70vh; text-align: center;
}
.centered-msg h2 { font-size: 1.6rem; color: var(--text2); }
.pulse-icon {
  font-size: 4rem;
  animation: pulse 2s ease-in-out infinite;
  margin-bottom: 1rem;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.1); opacity: .7; }
}

/* ── Player view ─────────────────────────────────────────── */
.view-header { display: flex; justify-content: flex-end; margin-bottom: 1.5rem; }
.player-name-badge {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: .3rem 1rem;
  font-size: .88rem; color: var(--text2);
}
.question-box { max-width: 760px; margin: 0 auto 2rem; text-align: center; }
.question-box h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700; margin-bottom: 1.2rem; line-height: 1.3;
}
.q-image {
  max-width: 100%; max-height: 340px;
  border-radius: var(--radius); object-fit: contain;
  margin-bottom: 1rem; box-shadow: var(--shadow);
}
#player-answer-area { max-width: 580px; margin: 0 auto; }
#player-answer-input {
  width: 100%; padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 1.05rem; resize: vertical; outline: none;
  transition: border var(--transition);
  margin-bottom: 1rem; font-family: inherit;
}
#player-answer-input:focus { border-color: var(--accent); }
#player-submit-btn { width: 100%; }
.submitted-badge {
  margin-top: 1rem; padding: .8rem 1.2rem;
  border-radius: 8px;
  background: rgba(108,99,255,.15); border: 1px solid var(--accent);
  color: var(--accent); text-align: center; font-size: .95rem;
}

/* ── Player result ───────────────────────────────────────── */
.result-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 70vh; text-align: center;
}
.result-icon { font-size: 5rem; margin-bottom: 1rem; }
.result-screen h2 { font-size: 2.5rem; font-weight: 800; margin-bottom: .5rem; }
.result-screen p { font-size: 1.2rem; color: var(--text2); }
.result-screen p strong { color: var(--text); }
.result-screen.correct h2 { color: var(--green); }
.result-screen.wrong h2   { color: var(--red); }
.result-screen.late h2    { color: var(--yellow); }

/* ── Monitor view ────────────────────────────────────────── */
.monitor-view { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.monitor-question-area {
  text-align: center; padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.monitor-question-area h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 800; max-width: 900px;
  margin: 0 auto 1rem; line-height: 1.25;
}
.monitor-question-area.small h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  font-weight: 700; color: var(--text2);
}
.monitor-answers-area { flex: 1; padding: 1.5rem 2rem 2rem; overflow-y: auto; }
.monitor-answers-area h3 {
  color: var(--text2); font-size: 1rem;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1rem;
}
.answer-count { margin-top: 1rem; color: var(--text2); font-size: .9rem; }
.answers-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .7rem;
}
.answer-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem 1rem; font-size: .95rem;
  transition: background var(--transition);
}
.answer-item .ans-name { font-weight: 600; color: var(--text2); font-size: .82rem; margin-bottom: .2rem; }
.answer-item .ans-text { color: var(--text); font-size: 1rem; }
.answer-item.correct { background: rgba(74,222,128,.1); border-color: var(--green); }
.answer-item.correct .ans-name { color: var(--green); }
.answer-item.wrong   { background: rgba(248,113,113,.1); border-color: var(--red); }
.answer-item.wrong .ans-name   { color: var(--red); }
.correct-answer-banner {
  background: rgba(74,222,128,.12); border: 2px solid var(--green);
  border-radius: var(--radius); padding: 1rem 1.5rem;
  font-size: 1.3rem; font-weight: 700; color: var(--green);
  margin-bottom: 1.5rem; text-align: center;
}
.correct-answer-banner span { font-size: 1.5rem; }
.monitor-video-area {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: #000;
}
#monitor-video-player { max-width: 100%; max-height: 100vh; width: 100%; }

/* ── Admin view ──────────────────────────────────────────── */
.admin-view { max-width: 960px; margin: 0 auto; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-header h1 { font-size: 1.6rem; }
.phase-badge {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: .25rem .9rem;
  font-size: .85rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
}
.phase-badge.question { color: var(--accent); border-color: var(--accent); }
.phase-badge.reveal   { color: var(--green);  border-color: var(--green); }
.phase-badge.video    { color: #ec4899;        border-color: #ec4899; }
.admin-section { margin-bottom: 2.5rem; }
.admin-section > h2 {
  font-size: 1.1rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1rem;
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.question-form label { display: block; font-size: .88rem; color: var(--text2); margin-bottom: .3rem; margin-top: 1rem; }
.question-form label:first-of-type { margin-top: 0; }
.required { color: var(--red); margin-left: 2px; }
.question-form textarea,
.question-form input[type="text"] {
  width: 100%; padding: .65rem .9rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text);
  font-size: .95rem; outline: none;
  transition: border var(--transition);
  font-family: inherit; resize: vertical;
}
.question-form textarea:focus,
.question-form input[type="text"]:focus { border-color: var(--accent); }
.upload-area {
  border: 2px dashed var(--border); border-radius: 8px;
  padding: 1.2rem; text-align: center; cursor: pointer;
  transition: border var(--transition), background var(--transition);
  position: relative;
}
.upload-area:hover { border-color: var(--accent); background: rgba(108,99,255,.04); }
.upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%;
}
.upload-area span { color: var(--text2); font-size: .9rem; }
.upload-area .preview {
  max-width: 100%; max-height: 180px;
  border-radius: 6px; object-fit: contain;
  margin-top: .5rem; pointer-events: none;
}
.upload-area video.preview { max-height: 180px; width: 100%; }
.clear-btn {
  margin-top: .5rem;
  background: rgba(248,113,113,.12); border: 1px solid var(--red);
  color: var(--red); border-radius: 6px;
  padding: .25rem .8rem; font-size: .82rem;
  display: block; width: fit-content;
  margin: .5rem auto 0; position: relative; z-index: 1;
}
.form-actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.2rem; }
.questions-list { margin-top: 1.2rem; display: flex; flex-direction: column; gap: .7rem; }
.q-list-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: .9rem 1.1rem;
  display: flex; align-items: flex-start; gap: 1rem;
}
.q-list-item .q-num {
  background: var(--bg3); border-radius: 50%;
  width: 28px; height: 28px; min-width: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700; color: var(--text2);
}
.q-list-item .q-info { flex: 1; }
.q-list-item .q-info strong { font-size: .95rem; }
.q-list-item .q-info small { display: block; color: var(--text2); font-size: .82rem; margin-top: .15rem; }
.q-list-item .q-actions { display: flex; gap: .5rem; }
.q-list-item .q-actions button {
  padding: .3rem .7rem; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text2); font-size: .82rem;
}
.q-list-item .q-actions button:hover     { border-color: var(--accent); color: var(--accent); }
.q-list-item .q-actions .del-btn:hover   { border-color: var(--red); color: var(--red); }
.control-card .control-row {
  display: flex; align-items: center;
  gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap;
}
.control-card .control-row label { font-size: .88rem; color: var(--text2); white-space: nowrap; }
.control-card select {
  flex: 1; min-width: 180px;
  padding: .6rem .9rem; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: .95rem; outline: none;
}
#admin-answers-list.card { min-height: 60px; padding: 1rem; }
#admin-answers-list .answer-item { background: var(--bg2); }

/* ── Admin tabs ──────────────────────────────────────────── */
.admin-tabs {
  display: flex; gap: .5rem;
  margin-bottom: 1.8rem;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: .8rem 1.4rem;
  border: none; background: none;
  color: var(--text2); font-size: .95rem; font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-color: var(--accent); }

/* ── Dynamic list rows (correct answers / hints) ────────────── */
.dynamic-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }
.dynamic-row { display: flex; gap: .5rem; align-items: center; }
.dynamic-row-input {
  flex: 1; padding: .6rem .85rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text);
  font-size: .92rem; outline: none; font-family: inherit;
  transition: border var(--transition);
}
.dynamic-row-input:focus { border-color: var(--accent); }
.dynamic-row-remove {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text2);
  font-size: .9rem; display: flex; align-items: center; justify-content: center;
}
.dynamic-row-remove:hover { border-color: var(--red); color: var(--red); }
.btn-secondary.small { padding: .4rem .9rem; font-size: .85rem; }

/* ── Hints (player / monitor) ───────────────────────────────── */
.hints-panel {
  max-width: 760px; margin: 0 auto 1.5rem;
  background: rgba(251,191,36,.08); border: 1px solid var(--yellow);
  border-radius: var(--radius); padding: 1rem 1.3rem;
}
.hints-panel h3 { color: var(--yellow); font-size: .95rem; margin-bottom: .6rem; }
.hints-list { display: flex; flex-direction: column; gap: .5rem; }
.hint-item { display: flex; gap: .6rem; align-items: flex-start; font-size: .95rem; }
.hint-item .hint-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--yellow); color: #111;
  border-radius: 50%; font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.hint-item .hint-text { color: var(--text); }
.monitor-question-area + .hints-panel,
.hints-panel { text-align: left; }

/* ── Admin hint controls ────────────────────────────────────── */
.hint-status { color: var(--text2); font-size: .9rem; }
.admin-hints-list.card { min-height: 50px; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.hint-overview-item {
  display: flex; gap: .6rem; align-items: center;
  padding: .5rem .8rem; border-radius: 8px;
  background: var(--bg2); font-size: .9rem;
}
.hint-overview-item.locked { color: var(--text2); opacity: .6; }
.hint-overview-item.unlocked { color: var(--text); border: 1px solid var(--yellow); }
.hint-overview-item .hint-icon { flex-shrink: 0; }

/* ── Explanation box (reveal screens) ───────────────────────── */
.explanation-box {
  max-width: 640px; margin: 1.2rem auto 0;
  background: rgba(108,99,255,.08); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.3rem;
  text-align: left;
}
.explanation-box h3 { color: var(--accent); font-size: .9rem; margin-bottom: .4rem; }
.explanation-box p { color: var(--text); font-size: .95rem; line-height: 1.5; }
.result-screen .explanation-box { margin-top: 1.5rem; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .35s ease both; }
