@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  --primary: #2D2554;
  --primary-dark: #1E1840;
  --primary-light: #4A3E80;
  --secondary: #3A3068;
  --accent: #2D2554;
  --accent-dark: #1E1840;
  --accent-light: #4A3E80;
  --success: #2EAD60;
  --danger: #D4423A;
  --warning: #E8A520;
  --bg: #F5C830;
  --bg-card: #1A1428;
  --bg-card-hover: #221A34;
  --bg-input: #14102A;
  --text: #FFFFFF;
  --text-dim: #C0B8D0;
  --text-muted: #8880A0;
  --glass: rgba(0, 0, 0, 0.08);
  --glass-border: rgba(255, 255, 255, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-full: 50px;
}

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

html { font-size: 16px; }

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  direction: rtl;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ===== Background ===== */
.bg-effects {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}

.bg-effects .orb {
  position: absolute; border-radius: 50%;
  filter: blur(100px); opacity: 0.15;
  animation: float 10s ease-in-out infinite;
}

.bg-effects .orb:nth-child(1) {
  width: 350px; height: 350px;
  background: rgba(30,24,64,0.15); top: -80px; right: -60px;
}
.bg-effects .orb:nth-child(2) {
  width: 300px; height: 300px;
  background: rgba(30,24,64,0.12); bottom: -60px; left: -60px;
  animation-delay: -4s;
}
.bg-effects .orb:nth-child(3) {
  width: 220px; height: 220px;
  background: rgba(30,24,64,0.1); top: 45%; left: 55%;
  animation-delay: -7s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-15px, 15px) scale(0.95); }
}

/* ===== Screens ===== */
.screen {
  display: none; min-height: 100dvh;
  position: relative; z-index: 1;
  padding: 20px; max-width: 500px; margin: 0 auto;
}
.screen.active { display: flex; flex-direction: column; }

/* ===== Home & Lobby — white bg, dark purple buttons ===== */
#screen-name, #screen-menu, #screen-create, #screen-join, #screen-room {
  background: #FFFFFF;
}
#screen-name .logo h1, #screen-menu .logo h1, #screen-create .logo h1, #screen-join .logo h1 {
  color: #1A1428;
}
#screen-name .logo-title, #screen-menu .logo-title {
  background: linear-gradient(135deg, #3A2E68, #2D2554);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#screen-name .subtitle, #screen-create .card-title, #screen-join .card-title {
  color: #6A6080;
}
#screen-name .btn-pink, #screen-menu .btn-pink, #screen-menu .btn-blue,
#screen-create .btn-pink, #screen-join .btn-blue {
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; box-shadow: 0 4px 20px rgba(45,37,84,0.3);
}
#screen-name .btn-pink:hover, #screen-menu .btn-pink:hover, #screen-menu .btn-blue:hover,
#screen-create .btn-pink:hover, #screen-join .btn-blue:hover {
  box-shadow: 0 6px 28px rgba(45,37,84,0.4); transform: translateY(-1px);
}
#screen-name .input {
  background: #FFFFFF; border-color: #D8D4E0; color: #1A1428;
}
#screen-name .input:focus { border-color: #4A3E80; }
#screen-name .input::placeholder { color: #A8A0B8; }
#screen-name label { color: #6A6080; }
#screen-create .card, #screen-join .card {
  background: #F4F2F8; border-color: #E8E4F0;
}
#screen-create .input, #screen-join .input {
  background: #FFFFFF; border-color: #D8D4E0; color: #1A1428;
}
#screen-create .input:focus, #screen-join .input:focus { border-color: #4A3E80; }
#screen-create .input::placeholder, #screen-join .input::placeholder { color: #A8A0B8; }
#screen-create label, #screen-join label { color: #6A6080; }
#screen-create .btn-secondary, #screen-join .btn-secondary {
  background: #F0ECF4; color: #6A6080; border-color: #E0DCE8;
}
#screen-create .toggle-label, #screen-join .toggle-label { color: #6A6080; }
#screen-create .toggle-row { border-bottom-color: #E8E4F0; }
#screen-create .toggle-switch { background: #E0DCE8; }
#screen-create .toggle-switch.active { background: #2EAD60; }
#screen-create .time-btn { background: #F0ECF4; border-color: #E0DCE8; color: #6A6080; }
#screen-create .time-btn.active { background: #2D2554; border-color: #2D2554; color: #FFFFFF; box-shadow: 0 4px 16px rgba(45,37,84,0.3); }

/* Room/Lobby white overrides */
#screen-room .room-code .label { color: #6A6080; }
#screen-room .room-code .code {
  background: linear-gradient(135deg, #2D2554, #4A3E80);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#screen-room .copy-btn {
  background: #F0ECF4; border-color: #E0DCE8; color: #6A6080;
}
#screen-room .card { background: #F4F2F8; border-color: #E8E4F0; }
#screen-room .card-title { color: #1A1428; }
#screen-room .players-list li {
  background: #FFFFFF; border: 1px solid #E8E4F0;
}
#screen-room .players-list li span { color: #1A1428; }
#screen-room .host-badge { background: rgba(45,37,84,0.1); color: #4A3E80; }
#screen-room .btn-accent {
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; box-shadow: 0 4px 20px rgba(45,37,84,0.3);
}
#screen-room #waiting-msg { color: #8880A0; }
#screen-room .time-btn {
  background: #F0ECF4; border-color: #E0DCE8; color: #6A6080;
}
#screen-room .time-btn.active {
  background: #2D2554; border-color: #2D2554; color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(45,37,84,0.3);
}

/* ===== Logo ===== */
.logo { text-align: center; padding: 24px 0 16px; }

.logo h1 { font-size: 3.5rem; font-weight: 900; line-height: 1.2; }

.logo-title {
  background: linear-gradient(135deg, #3A2E68, #2D2554);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo .subtitle {
  color: var(--text-muted); font-size: 0.95rem;
  margin-top: 4px; font-weight: 500;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 14px;
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: 14px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}

.card-title .icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

/* ===== Buttons ===== */
.btn {
  width: 100%; padding: 16px 24px; border: none;
  border-radius: var(--radius); font-family: 'Tajawal', sans-serif;
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: all 0.2s ease; display: flex;
  align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; box-shadow: 0 4px 20px rgba(45,37,84,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 25px rgba(45,37,84,0.4); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--glass); color: var(--text-dim);
  border: 1px solid var(--glass-border);
}

.btn-accent {
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; font-weight: 800; box-shadow: 0 4px 20px rgba(45,37,84,0.3);
}

.btn-success {
  background: linear-gradient(135deg, #5BAD8F, #4A9A7E);
  color: white; box-shadow: 0 4px 20px rgba(91, 173, 143, 0.2);
}

.btn-pink {
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; box-shadow: 0 4px 20px rgba(45,37,84,0.3);
}
.btn-pink:hover { box-shadow: 0 6px 25px rgba(45,37,84,0.4); transform: translateY(-1px); }

.btn-blue {
  background: linear-gradient(135deg, #3A2E68, #2D2554);
  color: #FFFFFF; box-shadow: 0 4px 20px rgba(58,46,104,0.3);
}
.btn-blue:hover { box-shadow: 0 6px 25px rgba(58,46,104,0.4); transform: translateY(-1px); }

.btn-sm { padding: 10px 20px; font-size: 0.9rem; border-radius: var(--radius-sm); }

/* Leave button */
.btn-leave {
  width: 100%; margin-top: 10px;
  background: transparent; color: #D4423A;
  border: 1px solid rgba(212,66,58,0.3); border-radius: var(--radius-sm);
  padding: 10px 14px; font-family: 'Tajawal', sans-serif;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-leave:active { background: rgba(212,66,58,0.1); }
#screen-room .btn-leave { color: #D4423A; border-color: rgba(212,66,58,0.3); }

.btn-end-game {
  width: 100%;
  background: #D4423A; color: #FFFFFF;
  border: none; border-radius: var(--radius-sm);
  padding: 14px 14px; font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(212,66,58,0.3);
}
.btn-end-game:active { background: #A82820; transform: scale(0.97); }

/* Confirm overlay */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(30,24,64,0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease-out;
}
.confirm-box {
  background: #1A1428; border-radius: var(--radius);
  padding: 28px 24px; max-width: 320px; width: 90%;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
}
.confirm-box .confirm-text {
  font-size: 1.1rem; font-weight: 700; color: #FFFFFF;
  margin-bottom: 20px;
}
.confirm-btns {
  display: flex; gap: 10px;
}
.confirm-btns button {
  flex: 1; padding: 12px; border: none; border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif; font-size: 0.95rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.confirm-btns button:active { transform: scale(0.95); }
.confirm-yes {
  background: #D4423A; color: #FFFFFF;
}
.confirm-no {
  background: rgba(255,255,255,0.1); color: #FFFFFF;
}

/* ===== Inputs ===== */
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--text-dim); margin-bottom: 6px;
}

.input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-input); border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'Tajawal', sans-serif; font-size: 1rem;
  font-weight: 500; transition: border-color 0.2s; direction: rtl;
}
.input:focus { outline: none; border-color: var(--primary-light); }
.input::placeholder { color: var(--text-muted); }

/* ===== Code Boxes (input) ===== */
.code-boxes {
  display: flex; gap: 10px; justify-content: center;
}
.code-box {
  width: 56px; height: 64px;
  background: #FFFFFF; border: 2px solid #D8D4E0;
  border-radius: 14px; text-align: center;
  font-family: 'Tajawal', sans-serif;
  font-size: 1.6rem; font-weight: 900;
  color: #1A1428; text-transform: uppercase;
  transition: border-color 0.2s;
  caret-color: #2D2554;
}
.code-box:focus { outline: none; border-color: #2D2554; }

/* ===== Code Display Boxes ===== */
.code-display-boxes {
  display: flex; gap: 10px; justify-content: center;
  margin: 12px 0;
}
.code-display-box {
  width: 60px; height: 70px;
  background: #2D2554;
  border: 2px solid #4A3E80;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Tajawal', monospace;
  font-size: 2rem; font-weight: 900;
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(45,37,84,0.3);
}
#screen-room .code-display-box {
  background: #2D2554; border-color: #4A3E80; color: #FFFFFF;
}

/* ===== Room Screen ===== */
.room-header { text-align: center; padding: 10px 0 5px; }

.room-code { text-align: center; padding: 16px 0 20px; }
.room-code .label {
  color: var(--text-muted); font-size: 0.85rem; margin-bottom: 6px; font-weight: 600;
}

.copy-btn {
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text-dim); padding: 8px 18px;
  border-radius: var(--radius-full); font-family: 'Tajawal', sans-serif;
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  margin-top: 8px; transition: all 0.2s;
}
.copy-btn:active { background: var(--primary); color: white; }

/* ===== Players List ===== */
.players-list { list-style: none; padding: 0; }

.players-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--glass);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  font-weight: 600; animation: slideIn 0.3s ease-out;
  border: 1px solid transparent;
}

.players-list li .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; color: white;
}

.players-list li .host-badge {
  margin-right: auto; font-size: 0.7rem;
  background: rgba(212, 184, 106, 0.15); color: var(--warning);
  padding: 3px 10px; border-radius: var(--radius-full); font-weight: 700;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Waiting Dots ===== */
.waiting-dots { display: inline-flex; gap: 4px; }
.waiting-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4A3E80; animation: bounce 1.4s ease-in-out infinite;
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== Letter Spinner (animation screen) ===== */
.letter-spinner { text-align: center; padding: 30px 20px; }

.round-badge {
  display: inline-block; padding: 6px 20px;
  background: #2D2554; border: 2px solid #2D2554;
  border-radius: var(--radius-full); font-size: 0.9rem;
  font-weight: 700; color: #FFFFFF; margin-bottom: 30px;
}

/* 5 over 5 grid for letter animations */
.letters-grid-anim {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  max-width: 320px; margin: 0 auto;
}

.letter-anim-square {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2D2554, #1E1840);
  color: #FFFFFF; font-size: 1.6rem; font-weight: 900;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(45,37,84,0.3);
  transition: transform 0.2s;
}

.letter-anim-square.spinning {
  animation: spin-letter 0.1s linear infinite;
}

.letter-anim-square.landed {
  animation: land 0.4s ease-out forwards;
}

@keyframes spin-letter { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes land { 0% { transform: scale(1.3); } 50% { transform: scale(0.92); } 100% { transform: scale(1); } }

/* ===== Game Header ===== */
.game-header {
  text-align: center; padding: 8px 0 14px;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.game-header-round {
  font-size: 0.9rem; color: #2D2554;
  font-weight: 700; letter-spacing: 0.5px;
}

/* ===== Game Sections ===== */
.game-section {
  margin-bottom: 20px;
}
.section-label {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #2D2554;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

/* ===== Letter Grid — 5 over 5 ===== */
.letter-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  max-width: 320px; margin: 0 auto;
}

.letter-square {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); color: #fff;
  font-size: 1.5rem; font-weight: 800;
  border-radius: 12px; cursor: pointer;
  transition: all 0.2s;
  border: 2px solid rgba(255,255,255,0.1);
  user-select: none;
  -webkit-user-select: none;
}
.letter-square:active { transform: scale(0.92); }

.letter-square.used {
  opacity: 0.25; transform: scale(0.9);
  background: #0E0A18; cursor: default;
  border-color: rgba(255,255,255,0.03);
}

/* ===== Word Grid — always 10 boxes in ONE line, dynamic sizing ===== */
.word-grid {
  display: flex; justify-content: center; gap: 4px;
  width: 100%; max-width: 360px; margin: 0 auto;
  flex-wrap: nowrap;
}

.word-square {
  flex: 1; min-width: 0;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: #fff;
  font-weight: 800;
  border-radius: 10px; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25,0.1,0.25,1);
  border: 2px dashed rgba(255,255,255,0.12);
  user-select: none;
  -webkit-user-select: none;
  font-size: 1.4rem;
}
/* Fewer letters = bigger boxes. As you type more, boxes shrink to fit 10 in a line */
.word-grid[data-count="0"] .word-square,
.word-grid[data-count="1"] .word-square { font-size: 2rem; }
.word-grid[data-count="2"] .word-square { font-size: 1.7rem; }
.word-grid[data-count="3"] .word-square { font-size: 1.5rem; }
.word-grid[data-count="4"] .word-square,
.word-grid[data-count="5"] .word-square { font-size: 1.3rem; }
.word-grid[data-count="6"] .word-square,
.word-grid[data-count="7"] .word-square { font-size: 1.1rem; }
.word-grid[data-count="8"] .word-square,
.word-grid[data-count="9"] .word-square,
.word-grid[data-count="10"] .word-square { font-size: 0.95rem; border-radius: 8px; }

.word-square.filled {
  background: var(--primary);
  border-style: solid;
  border-color: rgba(255,255,255,0.2);
  animation: popIn 0.2s ease;
}

@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== Timer ===== */
.timer {
  position: fixed; top: 20px; left: 20px; z-index: 100;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--bg-card); border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: border-color 0.3s, color 0.3s;
}
.timer.warning { border-color: var(--warning); color: var(--warning); animation: timer-pulse 0.5s ease-in-out infinite; }
.timer.danger { border-color: var(--danger); color: var(--danger); animation: timer-pulse 0.3s ease-in-out infinite; }

@keyframes timer-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ===== Submit Bar ===== */
.submit-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 14px 20px;
  background: linear-gradient(to top, #F5C830 70%, transparent);
  z-index: 50; display: flex; justify-content: center;
}
.submit-bar .btn { max-width: 500px; }

/* ===== Vote Screen ===== */
#screen-vote { justify-content: flex-start; }
.vote-header { text-align: center; padding: 16px 0; }

.vote-header .category-badge {
  display: inline-block; padding: 10px 28px;
  background: linear-gradient(135deg, #2D2554, #1E1840);
  border-radius: var(--radius-full); font-size: 1.3rem;
  font-weight: 800; color: #FFFFFF; margin-bottom: 10px;
}

.vote-instruction {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}

.vote-hint {
  font-size: 0.78rem; font-weight: 500; color: var(--text-muted);
  margin-bottom: 10px;
}

/* ===== Vote Answer Cards ===== */
.vote-answers { display: flex; flex-direction: column; gap: 10px; padding-bottom: 80px; }

.vote-answer-card {
  padding: 0; background: var(--bg-card);
  border: 2px solid var(--glass-border); border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 700;
  transition: all 0.25s; display: flex;
  align-items: center;
  -webkit-user-select: none; user-select: none;
  overflow: hidden;
}

.vote-answer-text {
  flex: 1; padding: 14px 12px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}

.vote-btn {
  width: 54px; min-height: 50px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800; cursor: pointer;
  transition: all 0.2s; border: none; background: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.vote-btn:active { transform: scale(0.85); }

.vote-btn-accept {
  background: #2EAD60;
  border-left: 1px solid var(--glass-border);
  color: #FFFFFF;
}
.vote-btn-accept.active {
  background: #1B8C4A;
  color: #FFFFFF;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.2);
}

.vote-btn-reject {
  background: #D4423A;
  border-right: 1px solid var(--glass-border);
  color: #FFFFFF;
}
.vote-btn-reject.active {
  background: #A82820;
  color: #FFFFFF;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.2);
}

.vote-answer-card.voted-accept {
  border-color: #2EAD60;
  background: #2EAD60;
  color: #FFFFFF;
}
.vote-answer-card.voted-accept .vote-answer-text { color: #FFFFFF; }
.vote-answer-card.voted-accept .vote-btn-reject { display: none; }
.vote-answer-card.voted-accept .vote-btn-accept { background: #1B8C4A; }

.vote-answer-card.voted-reject {
  border-color: #D4423A;
  background: #D4423A;
  color: #FFFFFF;
}
.vote-answer-card.voted-reject .vote-answer-text { color: #FFFFFF; }
.vote-answer-card.voted-reject .vote-btn-accept { display: none; }
.vote-answer-card.voted-reject .vote-btn-reject { background: #A82820; }

.vote-answer-card.duplicate {
  border-color: var(--glass-border);
  background: var(--bg-card);
  cursor: not-allowed;
}
.vote-answer-card.duplicate .vote-answer-text { color: var(--text-dim); }

.vote-answer-card .own-tag {
  font-size: 0.68rem; font-weight: 600; color: var(--text-muted);
  background: var(--glass); padding: 2px 8px; border-radius: var(--radius-full);
}

/* ===== Vote Status Bar ===== */
.vote-status-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 16px 20px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 50;
  text-align: center;
}
.vote-status-bar span {
  display: inline-block;
  padding: 10px 28px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 0.85rem; font-weight: 700;
  color: var(--text-dim);
}

/* ===== Time Selector ===== */
.time-options {
  display: flex; gap: 8px; margin-top: 12px;
}
.time-btn {
  flex: 1; padding: 12px 8px;
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.time-btn:active { transform: scale(0.95); }
.time-btn.active {
  border-color: var(--primary);
  background: rgba(45, 37, 84, 0.1);
  color: var(--primary-light);
  box-shadow: 0 0 12px rgba(45, 37, 84, 0.15);
}

/* ===== Vote Results ===== */
.vote-result-card {
  padding: 14px 16px; background: var(--bg-card);
  border: 2px solid var(--glass-border); border-radius: var(--radius);
  margin-bottom: 8px; display: flex; align-items: center;
  gap: 12px; animation: fadeIn 0.3s ease-out;
}
.vote-result-card .answer-text { flex: 1; font-size: 1rem; font-weight: 600; }
.vote-result-card .player-name { font-size: 0.78rem; color: var(--text-dim); }

.vote-result-card .score-badge {
  padding: 4px 14px; border-radius: var(--radius-full);
  font-weight: 800; font-size: 0.95rem;
}
.vote-result-card .score-badge.plus { background: rgba(91, 173, 143, 0.15); color: var(--success); }
.vote-result-card .score-badge.zero { background: rgba(212, 114, 107, 0.15); color: var(--danger); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Rankings ===== */
.rankings { padding: 20px 0; }
.rankings .rankings-title {
  text-align: center; font-size: 1.4rem; font-weight: 800; margin-bottom: 20px;
  color: #2D2554;
}

.rejoin-waiting {
  text-align: center;
  padding: 20px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  animation: slideUp 0.4s ease-out;
}

.rank-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--bg-card);
  border: 2px solid #2D2554;
  border-radius: var(--radius); margin-bottom: 10px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slideUp 0.4s ease-out;
}
.rank-item:nth-child(1) { border-color: #2D2554; background: #1E1840; }
.rank-item:nth-child(2) { border-color: #3A2E68; background: #2D2554; }
.rank-item:nth-child(3) { border-color: #4A3E80; background: #3A2E68; }

.rank-number {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1rem; background: var(--glass);
}
.rank-item:nth-child(1) .rank-number { background: linear-gradient(135deg, #FFD700, #FFA500); color: #333; }
.rank-item:nth-child(2) .rank-number { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #333; }
.rank-item:nth-child(3) .rank-number { background: linear-gradient(135deg, #CD7F32, #A0522D); color: #fff; }

.rank-name { flex: 1; font-weight: 700; font-size: 1.05rem; }
.rank-score { font-weight: 800; font-size: 1.15rem; color: #FFFFFF; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Game Over ===== */
.game-over-screen { text-align: center; padding: 30px 0; width: 100%; }

.winner-crown { font-size: 3.5rem; margin-bottom: 8px; animation: crown-bounce 1.5s ease-in-out infinite; }
@keyframes crown-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.winner-name {
  font-size: 2.2rem; font-weight: 900;
  background: linear-gradient(135deg, #2D2554, #1E1840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 4px;
}
.winner-label { color: #4A3E80; font-size: 1rem; margin-bottom: 24px; font-weight: 600; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; right: 20px; left: 20px;
  max-width: 380px; margin: 0 auto; padding: 12px 18px;
  border-radius: var(--radius); font-weight: 700;
  font-size: 0.9rem; z-index: 200; text-align: center;
  animation: toastIn 0.3s ease-out; pointer-events: none;
  backdrop-filter: blur(10px);
}
.toast.info { background: rgba(45, 37, 84, 0.95); color: white; }
.toast.warning { background: rgba(30, 24, 64, 0.95); color: white; }
.toast.success { background: rgba(91, 173, 143, 0.9); color: white; }

/* Mute Button */
.mute-btn {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.1);
  font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: all 0.2s;
}
.mute-btn:active { transform: scale(0.9); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .screen { max-width: 460px; padding: 30px; }
  .logo h1 { font-size: 4rem; }
  .letter-grid { max-width: 350px; gap: 10px; }
  .letter-anim-square { font-size: 1.8rem; }
  .letters-grid-anim { max-width: 350px; gap: 12px; }
  .word-grid { max-width: 400px; }
}

@media (max-width: 380px) {
  html { font-size: 14px; }
  .logo h1 { font-size: 2.8rem; }
  .letter-grid { max-width: 280px; gap: 5px; }
  .letter-square { font-size: 1.2rem; border-radius: 10px; }
  .letters-grid-anim { max-width: 280px; gap: 6px; }
  .letter-anim-square { font-size: 1.2rem; border-radius: 10px; }
  .word-grid { max-width: 300px; gap: 3px; }
}

@media (max-width: 340px) {
  .letter-grid { max-width: 260px; gap: 4px; }
  .letter-square { font-size: 1.1rem; border-radius: 8px; }
  .word-grid { max-width: 280px; gap: 2px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

/* Safe area */
@supports (padding-top: env(safe-area-inset-top)) {
  .screen { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .submit-bar { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .vote-status-bar { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .timer { top: calc(20px + env(safe-area-inset-top)); }
}

/* Avatars */
.avatar-1 { background: linear-gradient(135deg, #7C6FD4, #B0A8E8); }
.avatar-2 { background: linear-gradient(135deg, #5BA4B5, #88C9D8); }
.avatar-3 { background: linear-gradient(135deg, #C97B9A, #E4A8BE); }
.avatar-4 { background: linear-gradient(135deg, #D4B86A, #E8D494); }
.avatar-5 { background: linear-gradient(135deg, #D4726B, #E89E98); }
.avatar-6 { background: linear-gradient(135deg, #5BAD8F, #8CCAB2); }
.avatar-7 { background: linear-gradient(135deg, #6A9DBD, #9DC4DA); }
.avatar-8 { background: linear-gradient(135deg, #C4728F, #D998AE); }

/* ===== Toggle switch for public/private ===== */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.toggle-label { font-size: 0.9rem; font-weight: 600; }
.toggle-switch {
  width: 48px; height: 26px; border-radius: 13px;
  background: rgba(255,255,255,0.15); cursor: pointer;
  position: relative; transition: background 0.3s;
}
.toggle-switch.active { background: var(--success, #2EAD60); }
.toggle-switch::after {
  content: ''; position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; top: 2px; left: 2px;
  transition: transform 0.3s;
}
.toggle-switch.active::after { transform: translateX(22px); }

/* ===== Max players selector ===== */
.max-players-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.max-players-btns {
  display: flex; gap: 6px;
}
.max-players-btns button {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: transparent; color: #fff; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-size: 0.85rem;
}
.max-players-btns button.active {
  background: var(--primary, #2D2554); border-color: var(--primary, #2D2554);
}

/* ===== Public rooms list ===== */
.rooms-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.room-item {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border-radius: 12px;
  background: #F4F2F8; border: 1px solid #E8E4F0;
}
.room-item-info { display: flex; flex-direction: column; gap: 4px; }
.room-item-code { font-weight: 800; font-size: 1rem; letter-spacing: 3px; font-family: monospace; color: #2D2554; }
.room-item-meta { font-size: 0.8rem; color: #8880A0; }
.room-item .btn { width: 100%; }
.room-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 0;
  color: rgba(255,255,255,0.3); font-size: 0.8rem;
}
.room-divider::before, .room-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.08);
}
.no-rooms { text-align: center; padding: 20px; color: var(--text-dim, #C0B8D0); font-size: 0.85rem; }

/* White-bg overrides for join screen rooms list */
#screen-join .room-divider { color: #A8A0B8; }
#screen-join .room-divider::before, #screen-join .room-divider::after { background: #E0DCE8; }
#screen-join .no-rooms { color: #A8A0B8; }

/* Room badges */
.room-badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 0.7rem; font-weight: 700;
}
#screen-room .room-badge {
  background: rgba(45,37,84,0.1); color: #4A3E80;
}

/* Kick button */
.kick-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: #E74C3C; color: #fff; border: none;
  font-size: 0.75rem; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-right: auto; margin-left: 8px;
  transition: background 0.2s;
}
.kick-btn:hover { background: #C0392B; }

/* Room privacy toggle in lobby */
#room-privacy-toggle .toggle-switch { background: #E0DCE8; }
#room-privacy-toggle .toggle-switch.active { background: #2EAD60; }
#room-privacy-toggle .toggle-label { color: #6A6080; }

/* Category badge reuse */
.category-badge {
  display: inline-block; padding: 10px 28px;
  background: linear-gradient(135deg, #2D2554, #1E1840);
  border-radius: var(--radius-full); font-size: 1.3rem;
  font-weight: 800; color: #FFFFFF;
}
