:root {
    --c-blue-deep: #062a4a;
    --c-blue: #0e4d7a;
    --c-blue-bright: #1e7bb8;
    --c-blue-sky: #4ea8d8;
    --c-yellow: #f5c518;
    --c-yellow-bright: #ffd84d;
    --c-yellow-pale: #fff4c4;
    --c-cream: #fffaf0;
    --c-bg: #03162a;
    --c-bg-deep: #021022;
    --c-success: #2da664;
    --c-danger: #e04a5a;
    --shadow-deep: 0 30px 60px -20px rgba(0,0,0,0.7), 0 18px 36px -18px rgba(6,42,74,0.5);
    --shadow-card: 0 12px 28px -8px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 50px rgba(245,197,24,0.4);
    --font-display: 'Tajawal', sans-serif;
    --font-body: 'Tajawal', sans-serif;
    --font-cairo: 'Cairo', sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; overflow: hidden; }
  body {
    font-family: var(--font-body);
    background: var(--c-bg-deep);
    color: var(--c-cream);
    direction: rtl;
    -webkit-tap-highlight-color: transparent;
  }
  button, input { font-family: inherit; }

  .bg-layer {
    position: fixed; inset: 0; z-index: 0;
    background:
      radial-gradient(ellipse at top right, rgba(245,197,24,0.18) 0%, transparent 55%),
      radial-gradient(ellipse at bottom left, rgba(30,123,184,0.35) 0%, transparent 55%),
      radial-gradient(ellipse at center, rgba(14,77,122,0.25) 0%, transparent 70%),
      var(--c-bg-deep);
  }
  .bg-layer::before {
    content: ''; position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23f5c518' stroke-width='0.6' opacity='0.07'%3E%3Cpath d='M50 0 L100 50 L50 100 L0 50 Z'/%3E%3Cpath d='M50 15 L85 50 L50 85 L15 50 Z'/%3E%3Ccircle cx='50' cy='50' r='25'/%3E%3Cpath d='M0 50 Q25 30 50 50 T100 50' /%3E%3C/g%3E%3C/svg%3E");
    background-size: 100px 100px;
    pointer-events: none;
  }
  .bg-layer::after {
    content: ''; position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.5; pointer-events: none;
  }

  .app {
    position: relative; z-index: 1;
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; overflow: hidden;
  }
  .screen {
    flex: 1; display: none; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
  }
  .screen.active { display: flex; }
  .screen::-webkit-scrollbar { width: 8px; }
  .screen::-webkit-scrollbar-thumb { background: rgba(245,197,24,0.3); border-radius: 4px; }

  /* HOME */
  .home { align-items: center; padding: clamp(1.5rem, 4vw, 3rem); gap: clamp(1.5rem, 3vh, 2.5rem); }
  .brand { text-align: center; margin-top: clamp(1rem, 3vh, 2rem); animation: fadeUp 0.8s ease-out; }
  .brand-mark {
    font-family: var(--font-display); font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    color: var(--c-yellow); letter-spacing: 0.4em; margin-bottom: 0.6rem;
    opacity: 0.95; display: flex; align-items: center; justify-content: center; gap: 1rem;
    font-weight: 700;
  }
  .brand-mark::before, .brand-mark::after {
    content: ''; width: clamp(40px, 8vw, 80px); height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-yellow), transparent);
  }
  .title {
    font-family: var(--font-display); font-weight: 900;
    font-size: clamp(3.5rem, 9vw, 7rem); line-height: 0.95;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, var(--c-yellow-bright) 0%, var(--c-yellow) 50%, #b8890c 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 30px rgba(245,197,24,0.5));
    margin-bottom: 0.5rem;
  }
  .subtitle {
    font-family: var(--font-display); font-weight: 500;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: var(--c-blue-sky); opacity: 0.9;
  }
  .setup-card {
    background: linear-gradient(165deg, rgba(30,123,184,0.12) 0%, rgba(6,42,74,0.4) 100%);
    border: 1px solid rgba(245,197,24,0.3); border-radius: 24px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    width: 100%; max-width: 1100px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-deep);
    position: relative; animation: fadeUp 0.8s ease-out 0.1s backwards;
  }
  .setup-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--c-yellow), transparent);
  }
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .setup-section { margin-bottom: 2rem; }
  .setup-section:last-child { margin-bottom: 0; }
  .section-label {
    font-family: var(--font-display); font-size: clamp(1.05rem, 1.4vw, 1.25rem);
    color: var(--c-yellow-bright); margin-bottom: 1rem;
    display: flex; align-items: center; gap: 0.7rem; font-weight: 700;
  }
  .section-label::before {
    content: ''; width: 5px; height: 24px;
    background: linear-gradient(180deg, var(--c-yellow-bright) 0%, var(--c-blue-bright) 100%);
    border-radius: 2px;
  }
  .teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
  @media (max-width: 600px) { .teams-grid { grid-template-columns: 1fr; } }
  .team-input-wrap { position: relative; }
  .team-input-wrap label {
    position: absolute; top: -10px; right: 16px;
    background: var(--c-bg-deep); padding: 0 10px;
    font-size: 0.85rem; color: var(--c-yellow);
    font-weight: 700; z-index: 1; letter-spacing: 0.05em;
  }
  .team-input {
    width: 100%; padding: 1.1rem 1.3rem;
    background: rgba(3,22,42,0.6);
    border: 1.5px solid rgba(245,197,24,0.35);
    border-radius: 14px; color: var(--c-cream);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    font-weight: 700; direction: rtl;
    transition: all 0.25s ease;
  }
  .team-input:focus {
    outline: none; border-color: var(--c-yellow-bright);
    background: rgba(3,22,42,0.85);
    box-shadow: 0 0 0 4px rgba(245,197,24,0.15);
  }
  .team-input::placeholder { color: rgba(255,250,240,0.35); }

  .categories-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem;
  }
  .selected-count {
    font-size: 1rem; color: var(--c-cream);
    background: rgba(245,197,24,0.15);
    border: 1px solid rgba(245,197,24,0.4);
    padding: 0.5rem 1.1rem; border-radius: 50px; font-weight: 700;
  }
  .selected-count strong { color: var(--c-yellow-bright); font-size: 1.2rem; margin: 0 4px; }
  .selected-count.complete {
    background: rgba(45,166,100,0.2);
    border-color: var(--c-success); color: #95e3b8;
  }
  .categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.8rem;
  }
  .cat-tile {
    aspect-ratio: 1.25 / 1; border-radius: 16px; cursor: pointer;
    position: relative; overflow: hidden;
    border: 2px solid rgba(245,197,24,0.25);
    background: linear-gradient(160deg, rgba(30,123,184,0.15), rgba(6,42,74,0.3));
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.5rem; padding: 1rem 0.6rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .cat-tile::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(160deg, rgba(245,197,24,0.25), rgba(30,123,184,0.4));
    opacity: 0; transition: opacity 0.3s ease; z-index: 0;
  }
  .cat-tile:hover { transform: translateY(-3px); border-color: var(--c-yellow); }
  .cat-tile:hover::before { opacity: 0.4; }
  .cat-tile.selected {
    border-color: var(--c-yellow-bright);
    transform: scale(1.02); box-shadow: var(--shadow-glow);
  }
  .cat-tile.selected::before { opacity: 0.85; }
  .cat-tile.selected::after {
    content: '✓'; position: absolute;
    top: 8px; left: 8px;
    width: 28px; height: 28px;
    background: var(--c-yellow-bright);
    color: var(--c-blue-deep);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 1rem; z-index: 2;
  }
  .cat-tile.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
  .cat-tile-icon {
    font-size: clamp(2rem, 3.2vw, 2.6rem);
    z-index: 1; line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  }
  .cat-tile-name {
    font-family: var(--font-display);
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    font-weight: 800; color: var(--c-cream);
    z-index: 1; text-align: center; line-height: 1.2;
  }

  .options-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
  }
  .sound-toggle {
    display: flex; align-items: center; gap: 0.8rem;
    cursor: pointer; padding: 0.7rem 1.2rem;
    background: rgba(3,22,42,0.5);
    border: 1.5px solid rgba(245,197,24,0.3);
    border-radius: 50px; transition: all 0.25s ease; user-select: none;
  }
  .sound-toggle:hover { border-color: var(--c-yellow); }
  .sound-toggle .label { font-size: 1rem; font-weight: 700; color: var(--c-cream); }
  .toggle-track {
    width: 44px; height: 24px;
    background: rgba(0,0,0,0.4); border-radius: 50px;
    position: relative; transition: background 0.3s ease;
  }
  .toggle-thumb {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px;
    background: var(--c-cream); border-radius: 50%;
    transition: all 0.3s ease;
  }
  .sound-toggle.on .toggle-track { background: var(--c-yellow); }
  .sound-toggle.on .toggle-thumb { right: 22px; background: var(--c-bg-deep); }

  .btn {
    font-family: var(--font-display); font-weight: 800;
    border-radius: 14px; padding: 1rem 2rem;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    cursor: pointer; transition: all 0.25s ease;
    border: 2px solid transparent;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.6rem; white-space: nowrap;
  }
  .btn-primary {
    background: linear-gradient(165deg, var(--c-yellow-bright) 0%, var(--c-yellow) 50%, #c89a0e 100%);
    color: var(--c-blue-deep); box-shadow: var(--shadow-card);
    border-color: var(--c-yellow-bright);
  }
  .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card), 0 0 0 8px rgba(245,197,24,0.2);
  }
  .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
  .btn-ghost { background: transparent; color: var(--c-cream); border-color: rgba(255,250,240,0.35); }
  .btn-ghost:hover { background: rgba(255,250,240,0.06); border-color: var(--c-cream); }
  .btn-danger { background: var(--c-danger); color: var(--c-cream); border-color: var(--c-danger); }
  .btn-danger:hover { background: #c43c4a; transform: translateY(-2px); }
  .btn-success { background: var(--c-success); color: var(--c-cream); border-color: var(--c-success); }
  .btn-success:hover { background: #258752; transform: translateY(-2px); }
  .btn-large { padding: 1.3rem 3rem; font-size: clamp(1.1rem, 1.5vw, 1.3rem); }

  /* BOARD */
  .board-screen { padding: 0; overflow: hidden; }
  .board-header {
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: clamp(0.7rem, 1.5vw, 1.2rem) clamp(1rem, 3vw, 2.5rem);
    gap: 1rem;
    background: linear-gradient(180deg, rgba(3,22,42,0.95) 0%, rgba(3,22,42,0.7) 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(245,197,24,0.25);
    flex-shrink: 0;
  }
  .team-card {
    display: flex; align-items: center;
    gap: clamp(0.6rem, 1.5vw, 1rem);
    padding: clamp(0.5rem, 1.2vw, 0.8rem) clamp(0.8rem, 1.8vw, 1.3rem);
    background: rgba(255,250,240,0.04);
    border-radius: 18px;
    border: 2px solid transparent;
    transition: all 0.4s ease;
  }
  .team-card.team-1 { border-color: rgba(245,197,24,0.4); }
  .team-card.team-2 {
    border-color: rgba(78,168,216,0.5);
    justify-self: end; flex-direction: row-reverse;
  }
  .team-card.active.team-1 {
    background: linear-gradient(165deg, rgba(245,197,24,0.25), rgba(245,197,24,0.05));
    border-color: var(--c-yellow-bright);
    box-shadow: 0 0 30px rgba(245,197,24,0.35);
  }
  .team-card.active.team-2 {
    background: linear-gradient(165deg, rgba(78,168,216,0.3), rgba(30,123,184,0.05));
    border-color: var(--c-blue-sky);
    box-shadow: 0 0 30px rgba(78,168,216,0.35);
  }
  .team-emblem {
    width: clamp(44px, 5.5vw, 60px);
    height: clamp(44px, 5.5vw, 60px);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 900;
    font-size: clamp(1.1rem, 1.6vw, 1.5rem);
    flex-shrink: 0; position: relative;
  }
  .team-1 .team-emblem {
    background: linear-gradient(165deg, var(--c-yellow-bright), var(--c-yellow));
    color: var(--c-blue-deep);
  }
  .team-2 .team-emblem {
    background: linear-gradient(165deg, var(--c-blue-sky), var(--c-blue));
    color: var(--c-cream);
  }
  .team-emblem::after {
    content: ''; position: absolute; inset: -4px;
    border-radius: 50%;
    border: 2px dashed rgba(255,250,240,0.4);
    animation: spin 20s linear infinite;
    opacity: 0; transition: opacity 0.3s ease;
  }
  .team-card.active .team-emblem::after { opacity: 1; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .team-info { display: flex; flex-direction: column; }
  .team-2 .team-info { align-items: flex-end; }
  .team-name {
    font-family: var(--font-display);
    font-size: clamp(0.95rem, 1.3vw, 1.15rem);
    font-weight: 700; color: var(--c-cream); line-height: 1.1;
  }
  .team-score {
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 2.8vw, 2.3rem);
    font-weight: 900;
    color: var(--c-yellow-bright);
    line-height: 1;
  }
  .team-2 .team-score { color: var(--c-blue-sky); }
  .turn-indicator { text-align: center; padding: 0.5rem 0.5rem; }
  .turn-label {
    font-family: var(--font-display);
    font-size: clamp(0.75rem, 1vw, 0.85rem);
    color: var(--c-yellow);
    letter-spacing: 0.3em; margin-bottom: 0.2rem;
    font-weight: 600;
  }
  .turn-name {
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 1.5vw, 1.3rem);
    font-weight: 800; color: var(--c-cream);
  }
  .icon-btn {
    width: clamp(40px, 4.5vw, 48px);
    height: clamp(40px, 4.5vw, 48px);
    border-radius: 12px;
    background: rgba(255,250,240,0.06);
    border: 1.5px solid rgba(245,197,24,0.3);
    color: var(--c-cream); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem; transition: all 0.2s ease;
  }
  .icon-btn:hover { background: rgba(245,197,24,0.15); border-color: var(--c-yellow); }
  .board-wrap {
    flex: 1; overflow: auto;
    padding: clamp(1rem, 2.5vw, 2rem);
    display: flex; align-items: flex-start; justify-content: center;
  }
  .board {
    width: 100%; max-width: 1700px;
    display: grid; grid-template-columns: repeat(6, 1fr);
    gap: clamp(0.6rem, 1.2vw, 1.1rem);
  }
  .board-col {
    display: flex; flex-direction: column;
    gap: clamp(0.5rem, 0.9vw, 0.8rem);
    background: linear-gradient(180deg, rgba(30,123,184,0.08) 0%, rgba(6,42,74,0.15) 100%);
    border: 1px solid rgba(245,197,24,0.18);
    border-radius: 18px;
    padding: clamp(0.5rem, 0.9vw, 0.8rem);
  }
  .cat-header {
    background: linear-gradient(165deg, var(--c-blue-bright) 0%, var(--c-blue) 60%, var(--c-blue-deep) 100%);
    border: 2px solid var(--c-yellow);
    border-radius: 14px;
    padding: clamp(0.8rem, 1.6vw, 1.2rem) 0.5rem;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; gap: 0.5rem;
    box-shadow: var(--shadow-card);
    position: relative; overflow: hidden;
    min-height: clamp(85px, 10vw, 115px);
    justify-content: center;
  }
  .cat-header::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--c-yellow-bright), transparent);
  }
  .cat-header::after {
    content: ''; position: absolute;
    bottom: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-yellow), transparent);
    opacity: 0.5;
  }
  .cat-header-icon {
    font-size: clamp(1.6rem, 2.6vw, 2.2rem);
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  }
  .cat-header-name {
    font-family: var(--font-display);
    font-size: clamp(0.85rem, 1.15vw, 1.05rem);
    font-weight: 800; color: var(--c-yellow-bright);
    line-height: 1.2;
  }
  .point-cell {
    aspect-ratio: 1.7 / 1;
    background: linear-gradient(165deg, rgba(255,250,240,0.06) 0%, rgba(255,250,240,0.02) 100%);
    border: 1.5px solid rgba(245,197,24,0.35);
    border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 900;
    font-size: clamp(1.3rem, 2.4vw, 2.1rem);
    color: var(--c-yellow-bright);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative; overflow: hidden;
    letter-spacing: 0.02em;
  }
  .point-cell::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(165deg, rgba(245,197,24,0.18), transparent);
    opacity: 0; transition: opacity 0.3s ease;
  }
  .point-cell:hover:not(.used) {
    transform: translateY(-3px) scale(1.02);
    border-color: var(--c-yellow-bright);
    box-shadow: var(--shadow-glow);
    color: var(--c-cream);
  }
  .point-cell:hover:not(.used)::before { opacity: 1; }
  .point-cell.used {
    background: rgba(0,0,0,0.4);
    color: rgba(255,250,240,0.12);
    border-color: rgba(245,197,24,0.08);
    cursor: default;
    text-decoration: line-through;
  }
  .point-cell.level-easy { border-color: rgba(45,166,100,0.4); color: #6dd9a0; }
  .point-cell.level-medium { border-color: rgba(245,197,24,0.5); color: var(--c-yellow-bright); }
  .point-cell.level-hard { border-color: rgba(224,74,90,0.45); color: #ff7d8b; }
  .point-cell.level-easy:hover:not(.used) { border-color: #4ec98a; box-shadow: 0 0 30px rgba(45,166,100,0.3); }
  .point-cell.level-medium:hover:not(.used) { border-color: var(--c-yellow-bright); }
  .point-cell.level-hard:hover:not(.used) { border-color: #ff6b7a; box-shadow: 0 0 30px rgba(224,74,90,0.3); }

  /* QUESTION */
  .question-screen {
    padding: clamp(1rem, 2.5vw, 2rem);
    align-items: center; justify-content: center;
  }
  .question-card {
    width: 100%; max-width: 1100px;
    background: linear-gradient(165deg, rgba(30,123,184,0.15) 0%, rgba(6,42,74,0.5) 100%);
    border: 1.5px solid rgba(245,197,24,0.4);
    border-radius: 24px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    box-shadow: var(--shadow-deep);
    display: flex; flex-direction: column;
    gap: clamp(1rem, 2vw, 1.5rem);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    position: relative; animation: fadeUp 0.5s ease-out;
    max-height: 100%; overflow-y: auto;
  }
  .q-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem;
    padding-bottom: clamp(0.8rem, 1.5vw, 1.2rem);
    border-bottom: 1px solid rgba(245,197,24,0.25);
  }
  .q-meta { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
  .q-cat-badge {
    display: flex; align-items: center; gap: 0.5rem;
    background: rgba(30,123,184,0.4);
    border: 1px solid rgba(78,168,216,0.6);
    padding: 0.5rem 1rem; border-radius: 50px;
    font-family: var(--font-display);
    font-size: clamp(0.95rem, 1.15vw, 1.05rem);
    font-weight: 700; color: var(--c-cream);
  }
  .q-cat-badge .icon { font-size: 1.3rem; }
  .q-points-badge {
    background: linear-gradient(165deg, var(--c-yellow-bright), var(--c-yellow));
    color: var(--c-blue-deep);
    padding: 0.5rem 1.2rem; border-radius: 50px;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
  }
  .q-team-turn {
    font-family: var(--font-display);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    color: var(--c-yellow-bright); font-weight: 800;
  }
  .timer-wrap { display: flex; align-items: center; gap: 0.8rem; }
  .timer-ring {
    position: relative;
    width: clamp(60px, 7vw, 80px);
    height: clamp(60px, 7vw, 80px);
  }
  .timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
  .timer-ring circle { fill: none; stroke-width: 5; }
  .timer-ring .bg-circle { stroke: rgba(245,197,24,0.18); }
  .timer-ring .fg-circle {
    stroke: var(--c-yellow-bright);
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
  }
  .timer-ring.warning .fg-circle { stroke: var(--c-yellow); }
  .timer-ring.danger .fg-circle {
    stroke: var(--c-danger);
    animation: pulseDanger 0.8s ease-in-out infinite;
  }
  @keyframes pulseDanger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }
  .timer-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 900;
    font-size: clamp(1.4rem, 2.2vw, 1.8rem);
    color: var(--c-cream);
  }
  .timer-ring.danger .timer-text { color: var(--c-danger); }
  .q-body {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: clamp(1rem, 2vw, 1.5rem);
    text-align: center;
    padding: clamp(0.5rem, 1.5vw, 1rem) 0;
  }
  .q-text {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    font-weight: 700; color: var(--c-cream);
    line-height: 1.5; max-width: 850px;
  }
  .q-answer-reveal {
    background: linear-gradient(165deg, rgba(45,166,100,0.25), rgba(45,166,100,0.05));
    border: 2px solid var(--c-success);
    border-radius: 16px;
    padding: clamp(1rem, 2vw, 1.5rem);
    width: 100%; max-width: 650px;
    display: none;
    animation: fadeUp 0.5s ease-out;
  }
  .q-answer-reveal.show { display: block; }
  .q-answer-label {
    font-family: var(--font-display);
    font-size: 1rem;
    color: #95e3b8;
    margin-bottom: 0.5rem; letter-spacing: 0.1em;
    font-weight: 700;
  }
  .q-answer-text {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 2.1vw, 1.7rem);
    font-weight: 800; color: var(--c-cream);
  }
  .q-actions {
    display: flex; gap: 0.8rem;
    justify-content: center; flex-wrap: wrap;
    padding-top: clamp(0.8rem, 1.5vw, 1.2rem);
    border-top: 1px solid rgba(245,197,24,0.25);
  }

  /* RESULTS */
  .results-screen {
    padding: clamp(1.5rem, 4vw, 3rem);
    align-items: center; justify-content: center;
    gap: clamp(1rem, 2vw, 2rem);
  }
  .winner-trophy {
    font-size: clamp(4rem, 10vw, 7rem);
    filter: drop-shadow(0 8px 30px rgba(245,197,24,0.7));
    animation: trophyBounce 1.2s ease-out;
  }
  @keyframes trophyBounce {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
  }
  .winner-text { text-align: center; }
  .winner-mark {
    font-family: var(--font-display);
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--c-yellow);
    letter-spacing: 0.3em;
    margin-bottom: 0.5rem;
    font-weight: 700;
  }
  .winner-name {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    background: linear-gradient(180deg, var(--c-yellow-bright) 0%, var(--c-yellow) 50%, #b8890c 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 4px 25px rgba(245,197,24,0.5));
  }
  .winner-name.tie { color: var(--c-cream); -webkit-text-fill-color: var(--c-cream); }
  .results-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: clamp(0.8rem, 2vw, 1.5rem);
    width: 100%; max-width: 800px;
  }
  @media (max-width: 600px) { .results-grid { grid-template-columns: 1fr; } }
  .result-card {
    background: linear-gradient(165deg, rgba(255,250,240,0.06) 0%, rgba(255,250,240,0.01) 100%);
    border: 2px solid rgba(245,197,24,0.35);
    border-radius: 20px;
    padding: clamp(1.2rem, 2.5vw, 2rem);
    text-align: center;
    box-shadow: var(--shadow-card);
    position: relative;
  }
  .result-card.winner {
    border-color: var(--c-yellow-bright);
    background: linear-gradient(165deg, rgba(245,197,24,0.22), rgba(245,197,24,0.03));
    box-shadow: var(--shadow-glow);
  }
  .result-card.winner::before {
    content: '👑'; position: absolute;
    top: -22px; left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
  }
  .result-team-name {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 1.7vw, 1.5rem);
    font-weight: 800; color: var(--c-cream);
    margin-bottom: 0.5rem;
  }
  .result-team-score {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900; color: var(--c-yellow-bright);
    line-height: 1;
  }
  .result-team-label {
    font-family: var(--font-display);
    font-size: 1rem; color: var(--c-yellow);
    letter-spacing: 0.2em; margin-top: 0.3rem; opacity: 0.85;
    font-weight: 600;
  }
  .results-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

  /* MODAL */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(2,8,18,0.88);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none; align-items: center; justify-content: center;
    padding: 1rem;
  }
  .modal-backdrop.show { display: flex; animation: fadeUp 0.3s ease-out; }
  .modal {
    background: linear-gradient(165deg, var(--c-bg) 0%, var(--c-bg-deep) 100%);
    border: 1.5px solid rgba(245,197,24,0.45);
    border-radius: 20px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    max-width: 500px; width: 100%;
    text-align: center; box-shadow: var(--shadow-deep);
  }
  .modal-icon { font-size: 3rem; margin-bottom: 1rem; }
  .modal-title {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 2vw, 1.6rem);
    font-weight: 800;
    color: var(--c-yellow-bright);
    margin-bottom: 0.5rem;
  }
  .modal-text {
    font-size: clamp(1rem, 1.2vw, 1.05rem);
    color: var(--c-cream);
    margin-bottom: 1.5rem; line-height: 1.5;
    font-weight: 500;
  }
  .modal-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

  .confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
  .confetti-piece {
    position: absolute;
    width: 10px; height: 14px;
    top: -20px;
    animation: confettiFall linear forwards;
  }
  @keyframes confettiFall {
    to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
  }
  .exit-fab { position: absolute; bottom: 1rem; left: 1rem; z-index: 10; }

  @media (min-width: 1800px) {
    .title { font-size: 8rem; }
    .board { max-width: 1900px; }
    .point-cell { font-size: 2.6rem; }
    .cat-header-name { font-size: 1.25rem; }
    .cat-header-icon { font-size: 2.6rem; }
  }
  @media (max-width: 700px) {
    .board-header { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .turn-indicator { grid-column: 1 / -1; order: -1; padding: 0.3rem; }
    .board { gap: 0.4rem; }
    .board-col { padding: 0.3rem; gap: 0.4rem; }
    .cat-header { padding: 0.5rem 0.2rem; min-height: 70px; }
    .point-cell { font-size: 1.05rem; aspect-ratio: 1.5 / 1; }
    .q-header { gap: 0.5rem; }
  }
  @media (max-width: 500px) {
    .board { gap: 0.3rem; }
    .board-col { padding: 0.25rem; gap: 0.3rem; }
    .cat-header-icon { font-size: 1.2rem; }
    .cat-header-name { font-size: 0.7rem; }
    .point-cell { font-size: 0.9rem; }
  }
.disclaimer {
  text-align: center;
  padding: 24px 20px;
  margin-top: 30px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  font-family: 'Tajawal', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.7;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.disclaimer p {
  margin: 6px 0;
}
.disclaimer p:last-child {
  font-size: 11px;
  opacity: 0.8;
  font-family: 'Cairo', sans-serif;
  direction: ltr;
}

/* ==================== أسئلة الوسائط (Audio & Image) ==================== */

/* مشغل الصوت المخصص */
.q-audio-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 20px auto;
  padding: 18px 22px;
  background: linear-gradient(135deg, rgba(245,197,24,0.14), rgba(245,197,24,0.04));
  border: 1px solid rgba(245,197,24,0.30);
  border-radius: 18px;
  max-width: 600px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

/* زر التشغيل / الإيقاف */
.q-audio-btn {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--c-yellow-bright), var(--c-yellow));
  color: var(--c-blue-deep);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(245,197,24,0.45), inset 0 2px 4px rgba(255,255,255,0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.q-audio-btn:hover { transform: scale(1.06); }
.q-audio-btn:active { transform: scale(0.96); }

/* تبديل أيقونة التشغيل/الإيقاف */
.q-audio-btn .ic-pause { display: none; }
.q-audio-wrap.playing .q-audio-btn .ic-play { display: none; }
.q-audio-wrap.playing .q-audio-btn .ic-pause { display: inline; }

.q-audio-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* أعمدة الموجة الصوتية */
.q-audio-bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
}
.q-audio-bars span {
  flex: 1;
  min-width: 3px;
  border-radius: 4px;
  background: linear-gradient(var(--c-yellow-bright), var(--c-yellow));
  height: 28%;
  transition: height 0.18s ease;
  animation: wave-bar 1s ease-in-out infinite;
  animation-play-state: paused;
}
.q-audio-wrap.playing .q-audio-bars span {
  animation-play-state: running;
}
/* ارتفاعات متدرجة لتشبه الموجة في الصورة */
.q-audio-bars span:nth-child(1)  { height: 20%; animation-delay: 0.0s; }
.q-audio-bars span:nth-child(2)  { height: 38%; animation-delay: 0.1s; }
.q-audio-bars span:nth-child(3)  { height: 60%; animation-delay: 0.2s; }
.q-audio-bars span:nth-child(4)  { height: 85%; animation-delay: 0.3s; }
.q-audio-bars span:nth-child(5)  { height: 100%; animation-delay: 0.15s; }
.q-audio-bars span:nth-child(6)  { height: 72%; animation-delay: 0.25s; }
.q-audio-bars span:nth-child(7)  { height: 45%; animation-delay: 0.05s; }
.q-audio-bars span:nth-child(8)  { height: 30%; animation-delay: 0.35s; }
.q-audio-bars span:nth-child(9)  { height: 55%; animation-delay: 0.2s; }
.q-audio-bars span:nth-child(10) { height: 90%; animation-delay: 0.1s; }
.q-audio-bars span:nth-child(11) { height: 100%; animation-delay: 0.3s; }
.q-audio-bars span:nth-child(12) { height: 78%; animation-delay: 0.0s; }
.q-audio-bars span:nth-child(13) { height: 50%; animation-delay: 0.22s; }
.q-audio-bars span:nth-child(14) { height: 33%; animation-delay: 0.12s; }
.q-audio-bars span:nth-child(15) { height: 58%; animation-delay: 0.28s; }
.q-audio-bars span:nth-child(16) { height: 82%; animation-delay: 0.08s; }
.q-audio-bars span:nth-child(17) { height: 65%; animation-delay: 0.18s; }
.q-audio-bars span:nth-child(18) { height: 42%; animation-delay: 0.32s; }
.q-audio-bars span:nth-child(19) { height: 28%; animation-delay: 0.04s; }
.q-audio-bars span:nth-child(20) { height: 18%; animation-delay: 0.24s; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.45); }
  50%      { transform: scaleY(1); }
}

.q-audio-time {
  font-size: 13px;
  color: var(--c-yellow-pale);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
}

/* صورة السؤال */
.q-image-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
  max-width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(212, 175, 55, 0.25);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.q-image-wrap img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
  border-radius: 18px;
}

/* تجاوب للجوال */
@media (max-width: 600px) {
  .q-audio-wrap {
    padding: 14px 16px;
    gap: 14px;
    margin: 14px auto;
  }
  .q-audio-btn {
    width: 54px;
    height: 54px;
    font-size: 18px;
  }
  .q-audio-bars { height: 36px; }
  .q-image-wrap img {
    max-height: 220px;
  }
}

/* ==================== مجموعات الفئات (Category Groups) ==================== */

/* تعديل شبكة الفئات الرئيسية لتصبح عمودية */
.categories-grid {
  display: flex !important;
  flex-direction: column;
  gap: 12px;
}

/* حاوية المجموعة الواحدة */
.cat-group {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.cat-group:hover {
  border-color: rgba(245, 197, 24, 0.2);
}

/* عنوان المجموعة */
.cat-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--group-color, #f5c518) 12%, transparent),
    color-mix(in srgb, var(--group-color, #f5c518) 4%, transparent)
  );
  border-bottom: 1px solid transparent;
  transition: all 0.25s ease;
}

.cat-group-header:hover {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--group-color, #f5c518) 18%, transparent),
    color-mix(in srgb, var(--group-color, #f5c518) 6%, transparent)
  );
}

.cat-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--c-cream);
}

.cat-group-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.cat-group-name {
  letter-spacing: 0.3px;
}

.cat-group-count {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  margin-right: 4px;
}

.cat-group-toggle {
  color: var(--group-color, #f5c518);
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* لما المجموعة مفتوحة، السهم يدور */
.cat-group.expanded .cat-group-toggle {
  transform: rotate(180deg);
}

.cat-group.expanded .cat-group-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* شبكة الفئات داخل المجموعة */
.cat-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 15px;
  padding: 0 14px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s ease,
    opacity 0.25s ease;
}

.cat-group.expanded .cat-group-grid {
  max-height: 1000px;
  padding: 14px;
  opacity: 1;
}

/* علامة الوسائط (صوت/صورة) على البطاقة */
.cat-tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  z-index: 3;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}

.cat-tile-badge.audio-badge {
  background: rgba(155, 89, 182, 0.6);
  border-color: rgba(155, 89, 182, 0.8);
}

.cat-tile-badge.image-badge {
  background: rgba(52, 152, 219, 0.6);
  border-color: rgba(52, 152, 219, 0.8);
}

@media (max-width: 600px) {
  .cat-group-header {
    padding: 12px 14px;
  }
  .cat-group-title {
    font-size: 1rem;
    gap: 8px;
  }
  .cat-group-icon {
    font-size: 1.3rem;
  }
  .cat-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  .cat-group.expanded .cat-group-grid {
    padding: 10px;
  }
  .cat-tile-badge {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    top: 6px;
    right: 6px;
  }
}
