:root {
    --bg: #0f172a;
    --card-bg: #020617;
    --card-border: #1e293b;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.14);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --warn: #f97316;
    --warn-soft: rgba(249, 115, 22, 0.12);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.14);
    --radius-lg: 18px;
    --radius-md: 10px;
  }
  
  * {
    box-sizing: border-box;
  }
  
  body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at top, #1d2536 0, #020617 45%, #000 100%);
    margin: 0;
    padding: 0;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  /* Üst bar */
  .top-bar {
    width: 100%;
    max-width: 1200px;
    padding: 16px 20px 0;
  }
  
  .top-bar-inner {
    background: rgba(15, 23, 42, 0.86);
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    backdrop-filter: blur(14px);
    box-shadow:
      0 18px 45px rgba(15, 23, 42, 0.85),
      0 0 0 1px rgba(15, 23, 42, 0.95);
  }
  
  .app-title {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .app-logo {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: radial-gradient(circle at 30% 20%, #fbbf24, #f97316 55%, #db2777);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #0b1120;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4);
  }
  
  .app-title-text {
    font-weight: 600;
    letter-spacing: 0.03em;
    font-size: 16px;
  }
  
  .app-subtitle {
    font-size: 12px;
    color: var(--muted);
  }
  
  .session-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
  }
  
  .pill {
    border-radius: 999px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.7);
  }
  
  .pill span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
  }
  
  .pill strong {
    font-size: 12px;
    color: var(--text);
  }
  
  main {
    width: 100%;
    max-width: 1200px;
    padding: 18px 20px 26px;
    flex: 1;
    display: flex;
    justify-content: center;
  }
  
  /* Genel layout: sol tahta, sağda video */
  #wrapper {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    width: 100%;
  }
  
  /* Satranç tarafı */
  #board-wrapper {
    position: relative;
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: radial-gradient(circle at top left, #111827, #020617);
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    padding: 14px 14px 14px;
    box-shadow:
      0 18px 40px rgba(15, 23, 42, 0.85),
      0 0 0 1px rgba(15, 23, 42, 0.9);
  }
  
  #board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-radius: var(--radius-md);
    background: radial-gradient(circle at top, #0b1120, #020617);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.9);
  }
  
  #board {
    width: min(520px, 72vw);
    max-width: 100%;
  }
  
  /* Çizim canvas'ı */
  #drawCanvas {
    position: absolute;
    pointer-events: none;
    top: 14px;
    left: 14px;
  }
  
  /* Emote overlay */
  #emoteOverlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.25s ease, transform 0.25s ease;
  }
  
  #emoteOverlay.show {
    opacity: 1;
    transform: scale(1);
  }
  
  .emote-bubble {
    min-width: 140px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.8);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.95);
    animation: floatUp 1.2s ease-out forwards;
  }
  
  .emote-icon {
    font-size: 26px;
  }
  
  .emote-text {
    font-size: 13px;
    font-weight: 500;
  }
  
  .emote-celebrate {
    border-color: rgba(74, 222, 128, 0.9);
    box-shadow: 0 0 0 1px rgba(21, 128, 61, 0.35), 0 18px 45px rgba(15, 23, 42, 0.95);
  }
  
  .emote-sad {
    border-color: rgba(248, 113, 113, 0.9);
    box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.4), 0 18px 45px rgba(15, 23, 42, 0.95);
  }
  
  @keyframes floatUp {
    0% { transform: translateY(12px); }
    100% { transform: translateY(-6px); }
  }
  
  /* Durum kartı */
  .board-footer {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.3);
  }
  
  .status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
  }
  
  .status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--accent-soft);
    color: #c7d2fe;
    border: 1px solid rgba(129, 140, 248, 0.7);
  }
  
  .status-chip.danger {
    background: var(--danger-soft);
    border-color: rgba(248, 113, 113, 0.7);
    color: #fecaca;
  }
  
  .status-chip.ok {
    background: var(--success-soft);
    border-color: rgba(74, 222, 128, 0.7);
    color: #bbf7d0;
  }
  
  .status-label {
    font-size: 12px;
    color: var(--muted);
  }
  
  #statusText {
    font-size: 14px;
    font-weight: 500;
  }
  
  .fen-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
  }
  
  #fenText {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px dashed rgba(148, 163, 184, 0.5);
    color: #e5e7eb;
    overflow-x: auto;
  }
  
  .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
  }
  
  .meta-pill {
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.9);
  }
  
  .quiz-info {
    font-size: 12px;
    margin-top: 4px;
    color: #e5e7eb;
  }
  
  .quiz-info span {
    color: #a5b4fc;
    font-weight: 500;
  }
  
  /* Butonlar */
  #controls {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  button {
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  }
  
  button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.6);
  }
  
  button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
  }
  
  button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  #drawModeBtn {
    background: var(--warn-soft);
    border-color: rgba(251, 146, 60, 0.8);
    color: #fed7aa;
  }
  
  #drawModeBtn.active {
    background: #fb923c;
    border-color: #ea580c;
    color: #0b1120;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7);
  }
  
  #clearDrawBtn {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(148, 163, 184, 0.6);
    color: var(--muted);
  }
  
  #resetBoardBtn {
    background: var(--danger-soft);
    border-color: rgba(248, 113, 113, 0.8);
    color: #fee2e2;
  }
  
  #rulesBtn {
    background: var(--accent-soft);
    border-color: rgba(129, 140, 248, 0.85);
    color: #e0e7ff;
  }
  
  #celebrateBtn {
    background: var(--success-soft);
    border-color: rgba(74, 222, 128, 0.9);
    color: #bbf7d0;
  }
  
  #sadBtn {
    background: var(--danger-soft);
    border-color: rgba(248, 113, 113, 0.9);
    color: #fecaca;
  }
  
  #startCallBtn {
    background: var(--success-soft);
    border-color: rgba(74, 222, 128, 0.9);
    color: #bbf7d0;
  }
  
  #startCallBtn:disabled {
    border-color: rgba(148, 163, 184, 0.5);
  }
  
  /* Puzzle dropdown */
  #puzzleSelect {
    padding: 6px 10px;
    min-width: 220px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.9);
    background: #020617;
    color: #e0f2fe;
    font-size: 12px;
    font-weight: 500;
    outline: none;
    appearance: auto;
  }
  
  #puzzleSelect option {
    background: #020617;
    color: #e5e7eb;
  }
  
  /* Video tarafı */
  #video-wrapper {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: radial-gradient(circle at top right, #111827, #020617);
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    padding: 12px 14px;
    box-shadow:
      0 18px 40px rgba(15, 23, 42, 0.85),
      0 0 0 1px rgba(15, 23, 42, 0.9);
  }
  
  #video-wrapper h2 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
  }
  
  .video-sub {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
  }
  
  .video-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    padding: 8px 6px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(30, 64, 175, 0.6);
  }
  
  .video-block .label {
    font-size: 11px;
    color: var(--muted);
  }
  
  video {
    width: 100%;
    max-width: 260px;
    aspect-ratio: 4 / 3;
    background: #000;
    border-radius: 10px;
    border: 1px solid rgba(30, 64, 175, 0.8);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.85);
  }
  
  #video-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 2px;
  }
  
  #callStatus {
    font-size: 11px;
    color: var(--muted);
    min-height: 16px;
  }
  
  /* Öğretmene özel butonları gizlemek için */
  .teacher-only {
    display: none;
  }
  
  /* Çizim modu açıkken cursor */
  .drawing-mode #board-container,
  .drawing-mode #drawCanvas {
    cursor: crosshair;
  }
  
  /* Responsiveness */
  @media (max-width: 960px) {
    #wrapper {
      flex-direction: column;
    }
    #video-wrapper {
      order: -1;
    }
  }
  
  @media (max-width: 600px) {
    .top-bar-inner {
      flex-direction: column;
      align-items: flex-start;
      gap: 8px;
    }
    main {
      padding: 14px 12px 22px;
    }
    #board-wrapper {
      padding: 10px 10px 10px;
    }
    #board-container {
      padding: 8px;
    }
    #controls {
      justify-content: flex-start;
    }
  }
  