:root {
      --player-color: #54d66a;
      --ai-color: #ff6b6b;
      --neutral-color: #8c8fa5;
      --panel-bg: rgba(15, 18, 32, 0.92);
      --panel-border: rgba(255, 255, 255, 0.08);
      --board-outline: rgba(255, 255, 255, 0.12);
      --text-muted: rgba(255, 255, 255, 0.65);
      --design-width: 1280;
      --design-height: 720;
    }

    * {
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;
      touch-action: none;
      -webkit-overflow-scrolling: none;
      overscroll-behavior: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }

    html {
      width: 100dvw;
      height: 100dvh;
    }

    body {
      font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
      background: #05060d;
      color: #f5f6ff;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100dvw;
      height: 100dvh;
      position: fixed;
      top: 0;
      left: 0;
    }

    #app {
      width: 100dvw;
      height: 100dvh;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      background: radial-gradient(ellipse at 30% 20%, #1a1f42, #05060d 70%);
      position: relative;
    }

    #game-wrapper {
      width: 100%;
      height: 100%;
      position: relative;
      display: flex;
      flex-direction: column;
      gap: 0;
      padding: 0;
      background: var(--panel-bg);
      overflow: hidden;
    }

    #top-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      padding: 6px 12px;
      background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(10, 15, 30, 0.9) 100%);
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      flex-shrink: 0;
      gap: 12px;
      height: 52px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    /* Score sections */
    #top-bar .score-section {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 4px 16px;
      border-radius: 8px;
      min-width: 80px;
      transition: all 0.3s ease;
    }

    #top-bar .score-section .score-label {
      font-size: 0.65rem;
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      opacity: 0.8;
    }

    #top-bar .score-section .score-value {
      font-size: 1.4rem;
      font-weight: 800;
      line-height: 1.1;
    }

    #top-bar .player-section {
      background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.1));
      border: 1px solid rgba(74, 222, 128, 0.3);
      color: #4ade80;
    }

    #top-bar .opponent-section {
      background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.1));
      border: 1px solid rgba(248, 113, 113, 0.3);
      color: #f87171;
    }

    /* Status bar - center section */
    #top-bar #statusBar {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      padding: 4px 16px;
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.08);
      transition: all 0.3s ease;
      max-width: 320px;
    }

    #top-bar #statusBar.your-turn {
      background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(22, 163, 74, 0.15));
      border-color: rgba(74, 222, 128, 0.5);
      box-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
    }

    #top-bar #statusBar.opponent-turn {
      background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
      border-color: rgba(248, 113, 113, 0.3);
    }

    /* Turn indicator */
    #top-bar .turn-indicator {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    #top-bar .turn-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #64748b;
      transition: all 0.3s ease;
    }

    #top-bar #statusBar.your-turn .turn-dot {
      background: #4ade80;
      box-shadow: 0 0 10px #4ade80;
      animation: pulse-dot 1.5s ease-in-out infinite;
    }

    #top-bar #statusBar.opponent-turn .turn-dot {
      background: #f87171;
      box-shadow: 0 0 6px rgba(248, 113, 113, 0.5);
    }

    @keyframes pulse-dot {
      0%, 100% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.2); opacity: 0.8; }
    }

    #top-bar .turn-text {
      font-size: 0.85rem;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #e2e8f0;
      transition: color 0.3s ease;
    }

    #top-bar #statusBar.your-turn .turn-text {
      color: #4ade80;
    }

    #top-bar #statusBar.opponent-turn .turn-text {
      color: #f87171;
    }

    /* Moves info */
    #top-bar .moves-info {
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 0.7rem;
      color: rgba(255, 255, 255, 0.6);
    }

    #top-bar .moves-count {
      font-weight: 700;
      color: #38bdf8;
      font-size: 0.8rem;
    }

    #top-bar .moves-label {
      opacity: 0.7;
    }

    #top-bar #statusBar.opponent-turn .moves-info {
      display: none;
    }

    /* Hide moves during mulligan/game over */
    #top-bar #statusBar.mulligan .moves-info,
    #top-bar #statusBar.game-over .moves-info {
      display: none;
    }

    #top-bar #statusBar.mulligan .turn-indicator,
    #top-bar #statusBar.game-over .turn-indicator {
      display: flex;
    }

    #main-area {
      display: flex;
      flex: 1;
      gap: 4px;
      padding: 0;
      min-height: 0;
      align-items: stretch;
    }

    #bottom-bar {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      padding: 2px 8px;
      background: rgba(0, 0, 0, 0.6);
      flex-shrink: 0;
      gap: 6px;
      height: 34px;
    }

    #bottom-bar button {
      flex: 1;
      max-width: 180px;
      padding: 6px 12px;
      font-size: 0.8rem;
      border-radius: 4px;
      height: 28px;
      font-weight: 600;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    #rotateOverlay {
      position: fixed;
      inset: 0;
      background: rgba(5, 6, 13, 0.98);
      color: #fff;
      z-index: 1000;
      display: none;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      text-align: center;
      padding: 20px;
      gap: 16px;
    }

    #rotateOverlay.visible {
      display: flex;
    }

    #rotateOverlay .rotate-icon {
      font-size: 3rem;
      animation: rotateHint 2s ease-in-out infinite;
    }

    #rotateOverlay .rotate-text {
      font-size: 1.2rem;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      max-width: 280px;
      line-height: 1.5;
    }

    @keyframes rotateHint {
      0%, 100% { transform: rotate(-15deg); }
      50% { transform: rotate(15deg); }
    }

    h1 {
      display: none;
    }

    #game {
      display: none;
    }

    #scores, #controls, #mainStacks {
      display: none;
    }

    #boardContainer {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: stretch;
      min-height: 0;
      min-width: 0;
      overflow: visible;
      padding: 0 8px;
    }

    #board {
      border-collapse: separate;
      border-spacing: 1px;
      margin: 0;
      padding: 0;
      border-radius: 0;
      background: transparent;
      border: none;
      table-layout: fixed;
      --board-cell-size: 163px;
    }

    #board td {
      width: var(--board-cell-size);
      height: var(--board-cell-size);
      min-width: var(--board-cell-size);
      min-height: var(--board-cell-size);
      max-width: var(--board-cell-size);
      max-height: var(--board-cell-size);
      text-align: center;
      vertical-align: middle;
      position: relative;
      cursor: pointer;
      background: radial-gradient(circle at 40% 20%, rgba(255,255,255,0.12), rgba(14,16,26,0.95));
      transition: transform 0.1s, box-shadow 0.2s, border-color 0.2s;
      overflow: hidden;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: 0 3px 10px rgba(0,0,0,0.4);
      touch-action: none;
      box-sizing: border-box;
    }

    #board td.player-control {
      box-shadow: inset 0 0 0 2px rgba(84, 214, 106, 0.7), 0 6px 16px rgba(84,214,106,0.15);
    }

    #board td.ai-control {
      box-shadow: inset 0 0 0 2px rgba(255, 107, 107, 0.7), 0 6px 16px rgba(255,107,107,0.15);
    }

    /* Legal placement tiles */
    #board td.legal-target {
      box-shadow: inset 0 0 0 2px #ffc107, 0 0 18px rgba(255, 193, 7, 0.3);
      border-color: rgba(255, 193, 7, 0.6);
    }

    #board td::after {
      content: '';
      position: absolute;
      inset: 6px;
      border-radius: 6px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.12s ease;
    }

    #board td.preview-origin::after {
      background: rgba(255, 235, 59, 0.45);
      opacity: 1;
    }

    #board td.preview-hit-add::after {
      background: rgba(255, 222, 89, 0.35);
      opacity: 1;
    }

    #board td.preview-hit-capture::after {
      background: rgba(255, 92, 92, 0.45);
      opacity: 1;
    }

    #board td.preview-hit-blocked::after {
      background: rgba(180, 184, 205, 0.25);
      border: 1px dashed rgba(255, 255, 255, 0.35);
      opacity: 1;
    }

    #board td.preview-hit-ability::after {
      background: rgba(244, 67, 54, 0.3);
      opacity: 1;
    }

    #board td.drag-hover {
      outline: 2px dashed #ffc107;
      outline-offset: -4px;
    }

    #board td.drag-hover {
      outline: 2px dashed #ffc107;
      outline-offset: -4px;
    }

    .cell-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      font-size: 0.9rem;
      padding: 4px 8px;
      height: 100%;
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      box-sizing: border-box;
      overflow: hidden;
    }

    .cell-top {
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      flex: 1;
    }

    .card-power {
      font-size: 0.85rem;
      font-weight: 700;
      opacity: 1;
      padding: 2px 8px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.2);
      color: #fff;
      line-height: 1.2;
    }

    .cell-icon {
      font-size: 3.2rem;
      filter: drop-shadow(0 2px 5px rgba(0,0,0,0.6));
      line-height: 1;
    }

    .card-empty {
      opacity: 0.25;
      letter-spacing: 0.1em;
      font-size: 0.6rem;
      line-height: 1;
    }

    .pawn-requirement {
      position: absolute;
      top: 6px;
      left: 6px;
      padding: 2px 6px;
      border-radius: 10px;
      font-size: 0.65rem;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      background: rgba(6, 8, 15, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.08);
      pointer-events: none;
    }

    .pawn-requirement.met {
      border-color: rgba(84, 214, 106, 0.6);
      color: var(--player-color);
    }

    .pawn-requirement.need {
      border-color: rgba(255, 107, 107, 0.6);
      color: var(--ai-color);
    }

    .pawn-requirement.replace {
      border-color: rgba(255, 193, 7, 0.7);
      color: #ffeb3b;
    }

    .pawn-requirement.blocked {
      opacity: 0.6;
    }

    .pawn-dots {
      position: absolute;
      bottom: 6px;
      left: 4px;
      right: 4px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      pointer-events: none;
    }

    .pawn-row {
      display: flex;
      gap: 4px;
    }

    .pawn-row.player {
      justify-content: flex-start;
    }

    .pawn-row.ai {
      justify-content: flex-end;
    }

    .pawn-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      box-shadow: 0 0 6px rgba(0,0,0,0.5);
    }

    .pawn-dot.player {
      background: var(--player-color);
    }

    .pawn-dot.ai {
      background: var(--ai-color);
    }

    .lane-score-indicator {
      position: absolute;
      width: clamp(16px, 3vw, 22px);
      height: clamp(16px, 3vw, 22px);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: clamp(0.6rem, 1.2vw, 0.75rem);
      font-weight: 600;
      z-index: 10;
      pointer-events: none;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
      line-height: 1;
    }

    .lane-score-indicator.player {
      background: var(--player-color);
      color: #1a1a1a;
      top: 50%;
      left: 4px;
      transform: translateY(-50%);
    }

    .lane-score-indicator.ai {
      background: var(--ai-color);
      color: #1a1a1a;
      top: 50%;
      right: 4px;
      transform: translateY(-50%);
    }

    @media (max-width: 768px) {
      .lane-score-indicator {
        width: clamp(14px, 2.5vw, 18px);
        height: clamp(14px, 2.5vw, 18px);
        font-size: clamp(0.55rem, 1vw, 0.65rem);
        bottom: 2px;
      }
      
      .lane-score-indicator.player {
        left: 2px;
      }
      
      .lane-score-indicator.ai {
        right: 2px;
      }
    }

    #handPanel {
      width: 230px;
      flex-shrink: 0;
      background: rgba(0, 0, 0, 0.15);
      border-radius: 0;
      padding: 1px;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      overflow: hidden;
    }

    /* For Player 2 (right side), reverse the flex direction to move hand to right */
    #main-area.player2-view {
      flex-direction: row-reverse;
    }

    #handPanel-header {
      display: none;
    }

    #handScroller {
      display: none;
    }

    #handScrollPrev,
    #handScrollNext {
      display: none;
    }

    #hand {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      grid-template-rows: repeat(2, 1fr);
      gap: 2px;
      width: 100%;
      height: 100%;
      overflow: visible;
    }

    .card-slot {
      display: flex;
      flex-direction: column;
      gap: 0;
      min-height: 0;
      width: 100%;
      height: 100%;
    }

    .card-slot-label {
      display: none;
    }

    .card-slot.upcoming-slot .card-slot-label {
      display: none;
    }

    .card-placeholder {
      border: 1px dashed rgba(255, 255, 255, 0.25);
      border-radius: 8px;
      padding: 4px;
      text-align: center;
      font-size: 0.6rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--text-muted);
      background: rgba(15, 23, 42, 0.5);
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .card-button {
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: linear-gradient(145deg, rgba(20, 28, 50, 0.95), rgba(8, 12, 24, 0.95));
      color: #eee;
      padding: 0;
      border-radius: 4px;
      cursor: pointer;
      width: 100%;
      height: calc(100% - 3px);
      min-width: 0;
      text-align: left;
      font-size: 0.65rem;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      position: relative;
      transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
      box-shadow: 0 2px 6px rgba(0,0,0,0.4);
      touch-action: none;
      --pattern-cell-size: 5px;
      overflow: hidden;
    }

    .card-button.card-button-static {
      cursor: default;
      opacity: 0.9;
    }

    .card-slot.upcoming-slot .card-button {
      border-color: rgba(255, 193, 7, 0.4);
      box-shadow: 0 0 18px rgba(255, 193, 7, 0.15);
    }

    .card-button.selected {
      border-color: rgba(84, 214, 106, 0.9);
      box-shadow: 0 0 18px rgba(84, 214, 106, 0.5), inset 0 0 0 2px rgba(84, 214, 106, 0.3);
      transform: translateY(-2px) scale(1.02);
    }

    /* Card color classes for PvP */
    .card-button.card-blue {
      border-color: #3b82f6;
      background: linear-gradient(145deg, rgba(59, 130, 246, 0.15), rgba(20, 28, 50, 0.95));
    }

    .card-button.card-blue.selected {
      border-color: #3b82f6;
      box-shadow: 0 0 18px rgba(59, 130, 246, 0.5), inset 0 0 0 2px rgba(59, 130, 246, 0.3);
    }

    .card-button.card-red {
      border-color: #ef4444;
      background: linear-gradient(145deg, rgba(239, 68, 68, 0.15), rgba(20, 28, 50, 0.95));
    }

    .card-button.card-red.selected {
      border-color: #ef4444;
      box-shadow: 0 0 18px rgba(239, 68, 68, 0.5), inset 0 0 0 2px rgba(239, 68, 68, 0.3);
    }

    #mulliganCards .card-button.selected {
      border-width: 2px;
    }

    .card-button:disabled {
      opacity: 0.4;
      cursor: default;
    }

    .card-label {
      font-weight: 600;
      letter-spacing: 0.01em;
    }

    .card-face {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      justify-content: space-between;
    }

    .card-top {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      flex-direction: column;
      padding: 3px;
      z-index: 1;
    }

    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      width: 100%;
      z-index: 2;
    }

    .card-pawn-requirement {
      display: flex;
      gap: 2px;
      align-items: center;
    }

    .card-pawn-icon {
      width: 8px;
      height: 8px;
      background: linear-gradient(135deg, #ffd700, #ffed4e);
      border-radius: 50%;
      box-shadow: 0 0 3px rgba(255, 215, 0, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.5rem;
      color: #1a1a1a;
      font-weight: bold;
    }

    .card-power-badge {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: linear-gradient(135deg, #ffd700, #ffed4e);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.6rem;
      font-weight: bold;
      color: #1a1a1a;
      box-shadow: 0 0 4px rgba(255, 215, 0, 0.6);
      flex-shrink: 0;
    }

    .card-icon-area {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      position: relative;
      min-height: 0;
      gap: 2px;
      padding: 0;
    }

    .card-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.4rem;
      filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
      position: relative;
      z-index: 1;
      flex-shrink: 0;
    }

    .card-pattern-overlay {
      position: relative;
      z-index: 2;
      opacity: 0.9;
      pointer-events: none;
      flex-shrink: 0;
    }

    .card-name-banner {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(0, 0, 0, 0.85);
      padding: 1px 2px;
      text-align: center;
      z-index: 3;
    }

    .card-name-banner .card-label {
      font-size: 0.4rem;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      color: #fff;
      letter-spacing: 0.02em;
    }

    .stat-chip {
      display: flex;
      flex-direction: column;
      padding: 2px 6px;
      border-radius: 6px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.04);
      font-size: 0.62rem;
      letter-spacing: 0.05em;
      min-width: 48px;
    }

    .stat-chip-label {
      font-size: 0.58rem;
      text-transform: uppercase;
      opacity: 0.75;
    }

    .stat-chip strong {
      display: block;
      font-size: 0.85rem;
      letter-spacing: 0.02em;
      color: #fff;
    }



    .pattern-grid {
      --cell-size: var(--pattern-cell-size, 10px);
      display: grid;
      grid-template-columns: repeat(5, var(--cell-size));
      grid-template-rows: repeat(5, var(--cell-size));
      gap: 1px;
    }

    .pattern-cell {
      width: var(--cell-size);
      height: var(--cell-size);
      background: #333;
      border-radius: 1px;
      opacity: 0.35;
    }

    .pattern-origin {
      background: #999;
      opacity: 1;
    }

    .pattern-hit {
      background: #ffc107;
      opacity: 1;
    }

    .pattern-ability {
      background: #f44336;
      opacity: 0.9;
    }

    #controls {
      display: none;
    }

    button {
      padding: 6px 12px;
      border-radius: 6px;
      border: none;
      cursor: pointer;
      background: #1976d2;
      color: #fff;
      font-weight: 600;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      border: 1px solid rgba(255, 255, 255, 0.1);
    }

    button.secondary {
      background: #555;
    }

    #selectedInfo {
      display: none;
    }

    .info-panel {
      width: 100%;
      border: 1px solid var(--panel-border);
      border-radius: 8px;
      padding: 8px 10px;
      background: rgba(10, 14, 28, 0.8);
      display: flex;
      flex-direction: column;
      gap: 4px;
      box-shadow: inset 0 0 8px rgba(0,0,0,0.35);
    }

    .info-title {
      font-size: 0.65rem;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--text-muted);
    }

    .info-body {
      font-size: 0.7rem;
      color: #f0f2ff;
      line-height: 1.3;
    }

    .info-card-name {
      font-weight: 600;
      font-size: 0.8rem;
    }

    .info-card-stats {
      display: flex;
      gap: 8px;
      font-size: 0.65rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-muted);
    }

    .info-placeholder {
      color: var(--text-muted);
      font-style: italic;
    }

    .overlay {
      position: fixed;
      inset: 0;
      background: rgba(3, 5, 12, 0.95);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      z-index: 500;
      overflow: hidden;
    }

    #mulliganOverlay {
      background: radial-gradient(circle at top, #1f254d, #05060d 65%);
    }

    #gameOverOverlay {
      background: radial-gradient(circle at center, #1a1f3a, #05060d 80%);
    }

    #gameOverOverlay .overlay-panel {
      width: 100vw;
      height: 100vh;
      max-width: 100vw;
      max-height: 100vh;
      background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(5, 8, 18, 0.95));
      border: none;
      border-radius: 0;
      box-shadow: none;
      padding: clamp(4px, 1.5vh, 12px) clamp(8px, 2vw, 20px) 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-sizing: border-box;
      position: relative;
    }

    #gameOverTitle {
      font-size: clamp(0.85rem, 2.5vh, 1.3rem);
      margin: 0 0 clamp(3px, 0.8vh, 6px) 0;
      text-align: center;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      flex-shrink: 0;
    }

    #gameOverContent {
      display: flex;
      flex-direction: column;
      gap: clamp(2px, 0.6vh, 5px);
      align-items: center;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
      justify-content: flex-start;
      padding-bottom: clamp(70px, 10vh, 90px); /* Increased padding to ensure button is visible */
      box-sizing: border-box;
      -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
      touch-action: pan-y; /* Enable vertical touch scrolling */
    }

    #gameOverWinner {
      font-size: clamp(0.8rem, 2.2vh, 1.2rem);
      font-weight: bold;
      text-align: center;
      padding: clamp(6px, 1.2vh, 10px) clamp(14px, 3.5vw, 18px);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.1);
      border: 2px solid rgba(255, 255, 255, 0.3);
      min-width: 200px;
      flex-shrink: 0;
    }

    #gameOverWinner.player-win {
      color: #4ade80;
      border-color: #4ade80;
      background: rgba(74, 222, 128, 0.15);
      box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
    }

    #gameOverWinner.ai-win {
      color: #f87171;
      border-color: #f87171;
      background: rgba(248, 113, 113, 0.15);
      box-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
    }

    #gameOverWinner.draw {
      color: #fbbf24;
      border-color: #fbbf24;
      background: rgba(251, 191, 36, 0.15);
      box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    }

    #gameOverScores {
      display: flex;
      gap: clamp(6px, 1.5vw, 14px);
      font-size: clamp(0.7rem, 1.8vh, 0.95rem);
      text-align: center;
      flex-shrink: 0;
    }

    .score-display {
      display: flex;
      flex-direction: column;
      gap: clamp(2px, 0.6vh, 5px);
      padding: clamp(6px, 1.2vh, 10px) clamp(10px, 2.5vw, 14px);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.1);
      min-width: 100px;
      flex: 1;
    }

    .score-label {
      font-size: 0.85em;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      opacity: 0.7;
    }

    .score-value {
      font-size: clamp(1.2em, 3vh, 1.5em);
      font-weight: bold;
    }

    .score-display.player-score .score-value {
      color: #4ade80;
    }

    .score-display.ai-score .score-value {
      color: #f87171;
    }

    .game-stats-display {
      width: 100%;
      margin-top: clamp(2px, 0.5vh, 4px);
      margin-bottom: 0;
      padding: clamp(2px, 0.6vh, 5px);
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 12px;
      flex: 0 0 auto;
      display: flex;
      flex-direction: column;
      overflow: visible;
    }

    .game-stats-display h3 {
      margin: 0 0 clamp(3px, 0.8vh, 6px) 0;
      font-size: clamp(0.65rem, 1.8vh, 0.85rem);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      text-align: center;
      color: var(--text-muted);
      flex-shrink: 0;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: clamp(3px, 0.8vh, 5px);
      text-align: center;
      flex-shrink: 0;
    }

    .stat-item {
      display: flex;
      flex-direction: column;
      gap: clamp(2px, 0.5vh, 4px);
    }

    .stat-label {
      font-size: clamp(0.55rem, 1.5vh, 0.65rem);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      opacity: 0.7;
    }

    .stat-value {
      font-size: clamp(0.8rem, 2vh, 1.1rem);
      font-weight: bold;
      color: var(--accent-color);
    }

    @media (max-width: 768px) {
      #gameOverOverlay .overlay-panel {
        padding: clamp(4px, 1.2vh, 10px) clamp(6px, 1.5vw, 12px) clamp(80px, 15vh, 100px) clamp(6px, 1.5vw, 12px); /* Bottom padding for button */
        padding-top: clamp(4px, 1.2vh, 10px);
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
      }

      #gameOverContent {
        padding-bottom: 0; /* Remove padding, let actions handle spacing */
        gap: clamp(2px, 0.5vh, 4px);
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y; /* Enable vertical touch scrolling */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
      }

      #gameOverOverlay .overlay-actions {
        padding: clamp(12px, 3vh, 16px) clamp(8px, 2vw, 20px);
        min-height: 70px;
        position: absolute; /* Keep absolute but ensure it's visible */
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 100;
        background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(5, 8, 18, 0.98));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
      }

      #gameOverTitle {
        font-size: clamp(0.75rem, 2vh, 1rem);
        margin: 0 0 clamp(2px, 0.5vh, 4px) 0;
      }

      #gameOverWinner {
        font-size: clamp(0.7rem, 1.8vh, 0.9rem);
        padding: clamp(5px, 1vh, 8px) clamp(10px, 2.5vw, 14px);
      }

      #gameOverScores {
        flex-direction: column;
        gap: clamp(3px, 0.8vh, 6px);
        width: 100%;
        font-size: clamp(0.65rem, 1.6vh, 0.85rem);
      }

      .score-display {
        width: 100%;
        padding: clamp(5px, 1vh, 8px) clamp(8px, 2vw, 10px);
      }

      .score-value {
        font-size: clamp(1em, 2vh, 1.2em);
      }

      .game-stats-display {
        padding: clamp(2px, 0.5vh, 4px);
        margin-top: clamp(1px, 0.3vh, 2px);
        margin-bottom: 0;
        max-height: 25vh;
      }

      .game-stats-display h3 {
        font-size: clamp(0.55rem, 1.3vh, 0.7rem);
        margin: 0 0 clamp(2px, 0.4vh, 3px) 0;
      }

      .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(2px, 0.5vh, 3px);
      }

      .stat-label {
        font-size: clamp(0.45rem, 1.1vh, 0.55rem);
      }

      .stat-value {
        font-size: clamp(0.65rem, 1.4vh, 0.85rem);
      }

      .overlay-actions {
        padding: clamp(6px, 1.2vh, 10px) clamp(6px, 1.5vw, 12px);
      }

      .overlay-actions button {
        padding: clamp(8px, 1.5vh, 10px) clamp(16px, 4vw, 20px);
        font-size: clamp(0.85rem, 2vh, 0.9rem);
        min-width: auto;
      }
    }

    .overlay.hidden {
      display: none;
    }

    .overlay-panel {
      width: 100%;
      height: 100%;
      max-width: none;
      max-height: none;
      background: transparent;
      border-radius: 0;
      border: none;
      box-shadow: none;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding: 20px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      overflow: hidden;
      justify-content: center;
    }

    #mulliganOverlay .overlay-panel {
      padding: 16px 20px;
    }

    @media (max-width: 768px) {
      #mulliganOverlay .overlay-panel {
        padding: 12px 16px;
        gap: 12px;
      }

      /* Settings Overlay Mobile */
      #settingsOverlay .overlay-panel {
        padding: clamp(12px, 2vh, 16px) clamp(12px, 3vw, 16px);
        padding-bottom: clamp(80px, 12vh, 100px); /* Space for close button */
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
      }

      .settings-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y; /* Enable vertical touch scrolling */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        padding-right: 8px;
      }

      #settingsOverlay .overlay-actions {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: clamp(12px, 2vh, 16px) clamp(12px, 3vw, 16px);
        background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(5, 8, 18, 0.98));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
        z-index: 10;
      }
    }

    .overlay-panel h2 {
      margin: 0;
      font-size: clamp(1rem, 3vw, 1.4rem);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      text-align: center;
      flex-shrink: 0;
    }

    /* Settings Overlay Specific Styles */
    #settingsOverlay .overlay-panel {
      justify-content: flex-start;
      padding: clamp(16px, 3vh, 24px) clamp(16px, 4vw, 24px);
    }

    .settings-content {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y; /* Enable vertical touch scrolling */
      padding-right: 4px; /* Space for scrollbar */
    }

    .settings-content::-webkit-scrollbar {
      width: 6px;
    }

    .settings-content::-webkit-scrollbar-track {
      background: rgba(255, 255, 255, 0.05);
      border-radius: 3px;
    }

    .settings-content::-webkit-scrollbar-thumb {
      background: rgba(212, 175, 55, 0.3);
      border-radius: 3px;
    }

    .settings-content::-webkit-scrollbar-thumb:hover {
      background: rgba(212, 175, 55, 0.5);
    }

    #settingsOverlay .overlay-actions {
      flex-shrink: 0;
      margin-top: auto;
    }

    #mulliganInfo {
      font-size: clamp(0.8rem, 2vw, 0.95rem);
      color: var(--text-muted);
      text-align: center;
      padding: 8px 12px;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 8px;
      margin: 0 auto;
      max-width: 600px;
    }

    #mulliganCards {
      display: flex;
      flex-direction: row;
      gap: 12px;
      justify-content: center;
      align-items: center;
      flex: 1;
      overflow: visible;
      padding: 8px;
      flex-wrap: wrap;
    }

    #mulliganCards .card-button {
      flex: 0 0 auto;
      width: clamp(90px, 15vw, 140px);
      max-width: 140px;
    }

    @media (max-width: 768px) {
      #mulliganCards {
        gap: 10px;
        padding: 4px;
      }

      #mulliganCards .card-button {
        width: clamp(80px, 16vw, 120px);
        max-width: 120px;
      }
    }

    @media (orientation: landscape) and (max-width: 1024px) {
      #mulliganCards {
        flex-direction: row;
        gap: 8px;
      }

      #mulliganCards .card-button {
        width: clamp(70px, 12vw, 110px);
        max-width: 110px;
      }
    }

    .overlay-actions {
      display: flex;
      gap: 12px;
      margin-top: 8px;
      justify-content: center;
      flex-wrap: wrap;
      flex-shrink: 0;
    }

    #gameOverOverlay .overlay-actions {
      margin: 0;
      padding: clamp(8px, 1.5vh, 12px) clamp(8px, 2vw, 20px);
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(5, 8, 18, 0.95));
      box-sizing: border-box;
      z-index: 10;
      /* Ensure button is always visible on mobile */
      min-height: 60px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .overlay-actions button {
      min-width: 140px;
      padding: 10px 20px;
      font-size: 0.9rem;
    }

    button[disabled] {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .drag-ghost {
      position: fixed;
      z-index: 200;
      pointer-events: none;
      background: rgba(10, 12, 24, 0.95);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 10px;
      padding: 8px 12px;
      font-size: 0.8rem;
      box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
      transform: translate(-50%, -50%);
    }

    #log {
      margin-top: 10px;
      padding: 8px;
      background: rgba(8, 10, 18, 0.8);
      border-radius: 6px;
      max-height: 200px;
      overflow-y: auto;
      width: 100%;
      font-size: 0.85rem;
      border: 1px solid var(--panel-border);
    }

    #log p {
      margin: 3px 0;
    }

    #laneScoresPanel {
      display: none;
    }

    #laneScores {
      font-size: 0.7rem;
      opacity: 0.95;
      letter-spacing: 0.02em;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      justify-content: center;
    }

    .lane-score-item {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 4px 8px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      background: rgba(255, 255, 255, 0.05);
      min-width: 80px;
    }

    .lane-score-header {
      font-size: 0.55rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      text-align: center;
      font-weight: 600;
    }

    .lane-score-values {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 4px;
    }

    .lane-score-player {
      color: var(--player-color);
      font-weight: 600;
      font-size: 0.75rem;
    }

    .lane-score-ai {
      color: var(--ai-color);
      font-weight: 600;
      font-size: 0.75rem;
    }

    .lane-score-separator {
      color: var(--text-muted);
      opacity: 0.5;
    }

    .lane-score-item.player-winning {
      border-color: rgba(84, 214, 106, 0.6);
      background: rgba(84, 214, 106, 0.1);
    }

    .lane-score-item.ai-winning {
      border-color: rgba(255, 107, 107, 0.6);
      background: rgba(255, 107, 107, 0.08);
    }

    .lane-chip {
      padding: 3px 8px;
      border-radius: 999px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      background: rgba(255, 255, 255, 0.05);
      font-size: 0.65rem;
    }

    .lane-chip.player-lead {
      border-color: rgba(84, 214, 106, 0.6);
      background: rgba(84, 214, 106, 0.15);
      color: var(--player-color);
    }

    .lane-chip.ai-lead {
      border-color: rgba(255, 107, 107, 0.6);
      background: rgba(255, 107, 107, 0.12);
      color: var(--ai-color);
    }

    .lane-chip.tie {
      color: var(--text-muted);
    }

    #aiThinkingOverlay {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: rgba(12, 15, 30, 0.95);
      border: 2px solid rgba(255, 107, 107, 0.6);
      border-radius: 16px;
      padding: 24px 32px;
      z-index: 100;
      display: none;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(8px);
      opacity: 0;
      transition: opacity 0.3s ease-out;
      pointer-events: none; /* Allow interaction with the board while indicator shows */
    }

    #aiThinkingOverlay.visible {
      display: flex;
      opacity: 1;
    }

    #aiThinkingOverlay.fading {
      opacity: 0;
    }

    #aiThinkingText {
      font-size: 1.1rem;
      color: var(--ai-color);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      font-weight: 600;
    }

    #aiThinkingDots {
      display: flex;
      gap: 6px;
    }

    .thinking-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--ai-color);
      animation: thinkingPulse 1.4s ease-in-out infinite;
    }

    .thinking-dot:nth-child(2) {
      animation-delay: 0.2s;
    }

    .thinking-dot:nth-child(3) {
      animation-delay: 0.4s;
    }

    @keyframes thinkingPulse {
      0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
      }
      50% {
        opacity: 1;
        transform: scale(1.2);
      }
    }

    #aiThinkingOverlay.passed {
      border-color: rgba(255, 107, 107, 0.9);
      background: rgba(255, 107, 107, 0.1);
    }

    #aiThinkingOverlay.passed #aiThinkingText {
      color: var(--ai-color);
    }

    #aiThinkingOverlay.passed #aiThinkingDots {
      display: none;
    }

    details.collapsible {
      display: none;
    }

    #logPanel {
      display: none;
    }

    #log {
      display: none;
    }

    /* Debug tab */
    #debugTab {
      display: none !important; /* Hidden for production */
      position: fixed;
      top: 120px;
      right: 0;
      background: rgba(15, 23, 42, 0.9);
      color: #e2e8f0;
      padding: 8px 12px;
      border-radius: 12px 0 0 12px;
      border: 1px solid rgba(255, 255, 255, 0.15);
      cursor: pointer;
      z-index: 1200;
      font-size: 0.85rem;
      letter-spacing: 0.04em;
    }

    #debugPanel {
      display: none !important; /* Hidden for production */
      position: fixed;
      top: 120px;
      right: 120px;
      width: 360px;
      max-height: 70vh;
      background: rgba(10, 14, 30, 0.95);
      color: #e2e8f0;
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 12px;
      box-shadow: 0 10px 40px rgba(0,0,0,0.5);
      padding: 12px;
      z-index: 1200;
      backdrop-filter: blur(6px);
      overflow: hidden;
    }

    #debugPanel header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }

    #debugViewSelect {
      flex: 1;
      background: rgba(255,255,255,0.05);
      color: #e2e8f0;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 8px;
      padding: 6px 8px;
      display: none; /* Single view: timeline log */
    }

    #debugDownloadBtn {
      background: rgba(255,255,255,0.08);
      color: #e2e8f0;
      border: 1px solid rgba(255,255,255,0.2);
      border-radius: 8px;
      padding: 6px 10px;
      cursor: pointer;
      font-size: 0.8rem;
    }

    #debugDownloadBtn:hover {
      background: rgba(255,255,255,0.15);
    }

    #debugVersionLabel {
      font-size: 0.75rem;
      color: rgba(226, 232, 240, 0.8);
      margin-left: 8px;
      white-space: nowrap;
    }

    /* Floating turn badge element has been removed from HTML */
    
    /* Waiting spinner for mulligan waiting phase */
    .waiting-spinner {
      width: 40px;
      height: 40px;
      margin: 20px auto;
      border: 4px solid rgba(255, 255, 255, 0.2);
      border-top-color: #4ade80;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    #debugContent {
      width: 100%;
      height: 55vh;
      background: rgba(255,255,255,0.03);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 8px;
      padding: 8px;
      overflow: auto;
      font-family: "SFMono-Regular", Consolas, Menlo, monospace;
      font-size: 0.78rem;
      line-height: 1.35;
      white-space: pre;
    }

    /* Login/Signup Overlay */
    #authOverlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      max-width: 100vw;
      max-height: 100vh;
      background: radial-gradient(ellipse at 50% 50%, #2d1b4e 0%, #1a0f2e 40%, #05060d 100%);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    #authOverlay::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(212, 175, 55, 0.1) 0%, transparent 70%);
      animation: rotate 20s linear infinite;
      pointer-events: none;
    }

    @keyframes rotate {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    #authOverlay.hidden {
      display: none;
    }

    #authPanel {
      background: linear-gradient(145deg, rgba(20, 15, 35, 0.98), rgba(10, 8, 20, 0.98));
      border: 2px solid rgba(212, 175, 55, 0.4);
      border-radius: 20px;
      padding: 48px 40px;
      max-width: 420px;
      width: 90%;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 40px rgba(212, 175, 55, 0.2), inset 0 0 20px rgba(212, 175, 55, 0.05);
      backdrop-filter: blur(10px);
      position: relative;
      z-index: 1;
      animation: fadeInUp 0.5s ease-out;
    }

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

    #authPanel::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      right: -2px;
      bottom: -2px;
      background: linear-gradient(45deg, rgba(212, 175, 55, 0.3), rgba(139, 69, 19, 0.3), rgba(212, 175, 55, 0.3));
      border-radius: 20px;
      z-index: -1;
      opacity: 0.6;
      animation: shimmer 3s ease-in-out infinite;
    }

    @keyframes shimmer {
      0%, 100% { opacity: 0.4; }
      50% { opacity: 0.8; }
    }

    #authPanel h2 {
      margin: 0 0 32px 0;
      text-align: center;
      text-transform: uppercase;
      letter-spacing: 0.15em;
      font-size: 1.8rem;
      background: linear-gradient(135deg, #d4af37, #f4e4bc, #d4af37);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      background-size: 200% auto;
      animation: gradientShift 3s ease infinite;
      font-weight: 700;
      text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
    }

    @keyframes gradientShift {
      0%, 100% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
    }

    .auth-form {
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .auth-form input {
      padding: 14px 16px;
      border: 2px solid rgba(212, 175, 55, 0.3);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
      font-size: 1rem;
      transition: all 0.3s ease;
      backdrop-filter: blur(5px);
    }

    .auth-form input::placeholder {
      color: rgba(255, 255, 255, 0.5);
    }

    .auth-form input:focus {
      outline: none;
      border-color: rgba(212, 175, 55, 0.8);
      background: rgba(255, 255, 255, 0.12);
      box-shadow: 0 0 20px rgba(212, 175, 55, 0.3), inset 0 0 10px rgba(212, 175, 55, 0.1);
      transform: translateY(-2px);
    }

    .auth-buttons {
      display: flex;
      gap: 12px;
      margin-top: 8px;
    }

    .auth-buttons button {
      flex: 1;
      padding: 14px 20px;
      border: none;
      border-radius: 10px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 1rem;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      position: relative;
      overflow: hidden;
    }

    .auth-buttons button::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0;
      height: 0;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.3);
      transform: translate(-50%, -50%);
      transition: width 0.6s, height 0.6s;
    }

    .auth-buttons button:hover::before {
      width: 300px;
      height: 300px;
    }

    .auth-buttons button:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }

    .auth-buttons button:active {
      transform: translateY(0);
    }

    .auth-buttons button.primary {
      background: linear-gradient(135deg, #d4af37, #f4e4bc);
      color: #1a0f2e;
      box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    }

    .auth-buttons button.primary:hover {
      box-shadow: 0 8px 25px rgba(212, 175, 55, 0.6);
    }

    .auth-buttons button.secondary {
      background: rgba(255, 255, 255, 0.12);
      color: #fff;
      border: 2px solid rgba(212, 175, 55, 0.3);
    }

    .auth-buttons button.secondary:hover {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(212, 175, 55, 0.5);
    }

    .auth-forgot-password {
      text-align: center;
      margin-top: 12px;
      font-size: 0.9rem;
    }

    .auth-forgot-password.hidden {
      display: none;
    }

    .auth-forgot-password a {
      color: var(--crown-gold);
      text-decoration: none;
      transition: color 0.2s ease;
    }

    .auth-forgot-password a:hover {
      color: #f4c430;
      text-decoration: underline;
    }

    .email-verification-notice {
      background: rgba(251, 191, 36, 0.15);
      border: 1px solid rgba(251, 191, 36, 0.4);
      border-radius: 12px;
      padding: 12px 16px;
      margin: 12px 0;
      text-align: center;
    }

    .email-verification-notice.hidden {
      display: none;
    }

    .verification-message {
      color: #fbbf24;
    }

    .verification-message p {
      margin: 0 0 8px 0;
      font-size: 0.9rem;
    }

    .auth-error {
      color: #f87171;
      font-size: 0.9rem;
      text-align: center;
      margin-top: 8px;
      padding: 10px;
      background: rgba(248, 113, 113, 0.1);
      border-radius: 8px;
      border: 1px solid rgba(248, 113, 113, 0.3);
      animation: shake 0.5s ease;
    }

    @keyframes shake {
      0%, 100% { transform: translateX(0); }
      25% { transform: translateX(-10px); }
      75% { transform: translateX(10px); }
    }

    /* Signup Agreement */
    .signup-agreement {
      margin: 16px 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .signup-agreement.hidden {
      display: none;
    }

    .agreement-checkbox {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      cursor: pointer;
      font-size: 0.9rem;
      color: var(--text-muted);
      line-height: 1.5;
    }

    .agreement-checkbox input[type="checkbox"] {
      margin-top: 3px;
      width: 18px;
      height: 18px;
      cursor: pointer;
      accent-color: var(--crown-gold);
      flex-shrink: 0;
    }

    .agreement-checkbox span {
      flex: 1;
    }

    .agreement-checkbox a {
      color: var(--crown-gold);
      text-decoration: none;
    }

    .agreement-checkbox a:hover {
      text-decoration: underline;
    }

    /* Cookie Consent Banner */
    .cookie-consent-banner {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: linear-gradient(145deg, rgba(20, 15, 35, 0.98), rgba(10, 8, 20, 0.98));
      border-top: 2px solid rgba(212, 175, 55, 0.4);
      padding: 20px;
      z-index: 10000;
      box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(212, 175, 55, 0.2);
      backdrop-filter: blur(12px);
      animation: slideUp 0.5s ease-out;
      overflow: hidden;
    }

    .cookie-consent-banner::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(212, 175, 55, 0.1) 0%, transparent 60%);
      animation: rotate 25s linear infinite;
      pointer-events: none;
      z-index: 0;
    }

    .cookie-consent-content {
      position: relative;
      z-index: 1;
    }

    .cookie-consent-banner.hidden {
      display: none;
    }

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

    .cookie-consent-content {
      max-width: 1200px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      gap: 20px;
      flex-wrap: wrap;
    }

    .cookie-consent-text {
      flex: 1;
      min-width: 300px;
    }

    .cookie-consent-text h3 {
      font-size: 1.2rem;
      color: var(--crown-gold);
      margin: 0 0 8px 0;
      font-weight: 600;
    }

    .cookie-consent-text p {
      font-size: 0.9rem;
      color: var(--text-muted);
      margin: 0;
      line-height: 1.6;
    }

    .cookie-consent-text a {
      color: var(--crown-gold);
      text-decoration: none;
    }

    .cookie-consent-text a:hover {
      text-decoration: underline;
    }

    .cookie-consent-buttons {
      display: flex;
      gap: 12px;
      flex-shrink: 0;
    }

    .cookie-btn {
      padding: 12px 24px;
      border: none;
      border-radius: 8px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 0.95rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .cookie-btn.accept {
      background: linear-gradient(135deg, #d4af37, #f4e4bc);
      color: #1a0f2e;
      box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    }

    .cookie-btn.accept:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
    }

    .cookie-btn.reject {
      background: rgba(255, 255, 255, 0.12);
      color: #fff;
      border: 2px solid rgba(212, 175, 55, 0.3);
    }

    .cookie-btn.reject:hover {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(212, 175, 55, 0.5);
      transform: translateY(-2px);
    }

    @media (max-width: 768px) {
      .cookie-consent-content {
        flex-direction: column;
        text-align: center;
      }

      .cookie-consent-buttons {
        width: 100%;
        justify-content: center;
      }

      .cookie-btn {
        flex: 1;
        max-width: 200px;
      }
    }

    /* Update Panel */
    .update-panel {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 10001;
      max-width: 600px;
      width: 90%;
      max-height: 80vh;
      background: linear-gradient(145deg, rgba(20, 15, 35, 0.98), rgba(10, 8, 20, 0.98));
      border: 2px solid rgba(212, 175, 55, 0.4);
      border-radius: 16px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 40px rgba(212, 175, 55, 0.2);
      backdrop-filter: blur(12px);
      animation: slideIn 0.3s ease-out;
      display: flex;
      flex-direction: column;
      overflow: hidden; /* Prevent panel itself from scrolling */
    }

    .update-panel.hidden {
      display: none;
    }

    @keyframes slideIn {
      from {
        transform: translate(-50%, -60%);
        opacity: 0;
      }
      to {
        transform: translate(-50%, -50%);
        opacity: 1;
      }
    }

    .update-panel-content {
      display: flex;
      flex-direction: column;
      height: 100%;
      max-height: 100%;
      position: relative;
      z-index: 1;
      overflow: hidden;
      min-height: 0; /* Important for flex scrolling */
    }

    .update-panel-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: clamp(12px, 2vh, 20px) clamp(16px, 3vw, 24px);
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      flex-shrink: 0;
    }

    .update-panel-title {
      font-size: clamp(1rem, 2.5vh, 1.3rem);
      color: var(--crown-gold);
      margin: 0;
      font-weight: 600;
      letter-spacing: 0.05em;
    }

    .update-panel-close {
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 2rem;
      line-height: 1;
      cursor: pointer;
      padding: 0;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      transition: all 0.2s ease;
    }

    .update-panel-close:hover {
      background: rgba(255, 255, 255, 0.1);
      color: white;
    }

    .update-panel-messages {
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
      padding: clamp(12px, 2vh, 20px) clamp(16px, 3vw, 24px);
      display: flex;
      flex-direction: column;
      gap: clamp(12px, 2vh, 16px);
      min-height: 0;
      max-height: 100%;
      -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
      touch-action: pan-y; /* Enable vertical touch scrolling */
    }

    .update-message {
      padding: clamp(12px, 2vh, 16px);
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 12px;
      border-left: 3px solid var(--crown-gold);
    }

    .update-message-title {
      font-size: clamp(0.9rem, 2vh, 1.1rem);
      font-weight: 600;
      color: white;
      margin: 0 0 clamp(6px, 1vh, 8px) 0;
    }

    .update-message-content {
      font-size: clamp(0.85rem, 1.8vh, 0.95rem);
      color: var(--text-muted);
      line-height: 1.6;
      margin: 0;
    }

    .update-message-content p {
      margin: 0 0 clamp(8px, 1.5vh, 12px) 0;
    }

    .update-message-content p:last-child {
      margin-bottom: 0;
    }

    .update-message-date {
      font-size: clamp(0.7rem, 1.5vh, 0.8rem);
      color: rgba(255, 255, 255, 0.4);
      margin-top: clamp(6px, 1vh, 8px);
      font-style: italic;
    }

    .update-panel-actions {
      padding: clamp(12px, 2vh, 16px) clamp(16px, 3vw, 24px);
      border-top: 1px solid rgba(255, 255, 255, 0.1);
      display: flex;
      justify-content: center;
      flex-shrink: 0;
    }

    .update-panel-dismiss {
      padding: clamp(10px, 1.8vh, 12px) clamp(24px, 5vw, 32px);
      background: var(--crown-gold);
      color: #0a080f;
      border: none;
      border-radius: 8px;
      font-size: clamp(0.9rem, 2vh, 1rem);
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .update-panel-dismiss:hover {
      background: #f4c430;
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
    }

    .update-panel-dismiss:active {
      transform: translateY(0);
    }

    @media (max-width: 768px) {
      .update-panel {
        width: 95%;
        max-height: 90vh;
        height: 90vh; /* Fixed height on mobile */
        top: 5vh; /* Position from top instead of center */
        transform: translate(-50%, 0); /* Remove vertical centering */
      }

      .update-panel-content {
        max-height: 100%;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      }

      .update-panel-header {
        padding: 12px 16px;
        flex-shrink: 0;
        min-height: 50px;
      }

      .update-panel-messages {
        padding: 12px 16px;
        flex: 1;
        min-height: 0; /* Critical for scrolling */
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y; /* Enable vertical touch scrolling */
        /* Force scrolling on mobile */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
      }

      .update-panel-actions {
        padding: 12px 16px;
        flex-shrink: 0;
        min-height: 60px;
      }

      .update-panel-dismiss {
        width: 100%;
        max-width: 200px;
      }
    }

    /* Mobile Landscape - Auth Panel */
    @media (orientation: landscape) and (max-height: 600px) {
      #authPanel {
        padding: clamp(16px, 3vh, 24px) clamp(20px, 4vw, 28px);
        max-width: 85vw;
        max-height: 92vh;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: clamp(12px, 2vh, 20px);
        -webkit-overflow-scrolling: touch;
      }

      #authPanel h2 {
        font-size: clamp(1.2rem, 4vh, 1.8rem);
        margin: 0 0 clamp(12px, 2vh, 20px) 0;
      }

      .auth-form {
        gap: clamp(10px, 2vh, 16px);
      }

      .auth-form input {
        padding: clamp(10px, 2vh, 12px) clamp(12px, 2.5vw, 14px);
        font-size: clamp(0.9rem, 2.5vh, 1rem);
        border-radius: clamp(8px, 1.5vh, 10px);
      }

      .auth-buttons {
        gap: clamp(8px, 1.5vw, 12px);
        margin-top: clamp(4px, 1vh, 8px);
      }

      .auth-buttons button {
        padding: clamp(10px, 2vh, 12px) clamp(16px, 3vw, 18px);
        font-size: clamp(0.85rem, 2.2vh, 0.95rem);
        border-radius: clamp(8px, 1.5vh, 10px);
      }

      .auth-error {
        font-size: clamp(0.75rem, 2vh, 0.85rem);
        padding: clamp(6px, 1.5vh, 8px);
        margin-top: clamp(4px, 1vh, 6px);
      }
    }

    /* Start Screen Overlay */
    #startScreenOverlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      max-width: 100vw;
      max-height: 100vh;
      background: radial-gradient(ellipse at 50% 50%, #2d1b4e 0%, #1a0f2e 40%, #05060d 100%);
      z-index: 999;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    #startScreenOverlay::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(212, 175, 55, 0.15) 0%, transparent 70%);
      animation: rotate 25s linear infinite;
      pointer-events: none;
    }

    #startScreenOverlay.hidden {
      display: none;
    }

    #startScreenPanel {
      background: linear-gradient(145deg, rgba(20, 15, 35, 0.98), rgba(10, 8, 20, 0.98));
      border: 2px solid rgba(212, 175, 55, 0.4);
      border-radius: 24px;
      padding: 50px 45px;
      max-width: 520px;
      width: 90%;
      box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 50px rgba(212, 175, 55, 0.25), inset 0 0 30px rgba(212, 175, 55, 0.08);
      backdrop-filter: blur(12px);
      text-align: center;
      position: relative;
      z-index: 1;
      animation: fadeInUp 0.6s ease-out;
    }

    #startScreenPanel::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      right: -2px;
      bottom: -2px;
      background: linear-gradient(45deg, rgba(212, 175, 55, 0.4), rgba(139, 69, 19, 0.4), rgba(212, 175, 55, 0.4));
      border-radius: 24px;
      z-index: -1;
      opacity: 0.7;
      animation: shimmer 4s ease-in-out infinite;
    }

    #startScreenPanel h2 {
      margin: 0 0 12px 0;
      font-size: 2.8rem;
      text-transform: uppercase;
      letter-spacing: 0.2em;
      background: linear-gradient(135deg, #d4af37, #f4e4bc, #ffd700, #d4af37);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      background-size: 200% auto;
      animation: gradientShift 4s ease infinite;
      font-weight: 800;
      text-shadow: 0 0 40px rgba(212, 175, 55, 0.6);
      position: relative;
    }

    #startScreenPanel h2::after {
      content: '';
      position: absolute;
      bottom: -8px;
      left: 50%;
      transform: translateX(-50%);
      width: 60px;
      height: 3px;
      background: linear-gradient(90deg, transparent, #d4af37, transparent);
      border-radius: 2px;
      animation: expandLine 1.5s ease-in-out infinite;
    }

    @keyframes expandLine {
      0%, 100% { width: 60px; opacity: 0.6; }
      50% { width: 120px; opacity: 1; }
    }

    #startScreenPanel .user-info {
      margin: 0 0 40px 0;
      opacity: 0.85;
      font-size: 1rem;
      color: rgba(255, 255, 255, 0.9);
      padding: 12px 20px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 12px;
      border: 1px solid rgba(212, 175, 55, 0.2);
      display: inline-block;
    }

    /* Mobile Landscape - Start Screen */
    @media (orientation: landscape) and (max-height: 600px) {
      #startScreenPanel {
        padding: clamp(16px, 3vh, 28px) clamp(20px, 4vw, 35px);
        max-width: 85vw;
        max-height: 92vh;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: clamp(16px, 3vh, 24px);
        -webkit-overflow-scrolling: touch;
      }

      #startScreenPanel h2 {
        font-size: clamp(1.8rem, 6vh, 2.8rem);
        margin: 0 0 clamp(8px, 1.5vh, 12px) 0;
        letter-spacing: clamp(0.1em, 0.5vw, 0.2em);
      }

      #startScreenPanel h2::after {
        width: clamp(40px, 8vw, 60px);
        height: clamp(2px, 0.5vh, 3px);
      }

      #startScreenPanel .user-info {
        margin: 0 0 clamp(20px, 4vh, 30px) 0;
        font-size: clamp(0.85rem, 2.5vh, 0.95rem);
        padding: clamp(8px, 1.5vh, 10px) clamp(14px, 3vw, 18px);
        border-radius: clamp(8px, 1.5vh, 12px);
      }

      .start-buttons {
        gap: clamp(12px, 2.5vh, 18px);
      }

      .start-buttons button {
        padding: clamp(12px, 2.5vh, 16px) clamp(20px, 4vw, 24px);
        font-size: clamp(0.95rem, 2.8vh, 1.1rem);
        border-radius: clamp(10px, 2vh, 14px);
      }
    }

    .start-buttons {
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .start-buttons button {
      padding: 18px 28px;
      border: none;
      border-radius: 14px;
      font-size: 1.15rem;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.3s ease;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      position: relative;
      overflow: hidden;
    }

    .start-buttons button::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0;
      height: 0;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.25);
      transform: translate(-50%, -50%);
      transition: width 0.6s, height 0.6s;
    }

    .start-buttons button:hover::before {
      width: 400px;
      height: 400px;
    }

    .start-buttons button:hover {
      transform: translateY(-3px);
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }

    .start-buttons button:active {
      transform: translateY(-1px);
    }

    .start-buttons button.play-ai {
      background: linear-gradient(135deg, #d4af37, #f4e4bc);
      color: #1a0f2e;
      box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
    }

    .start-buttons button.play-ai:hover {
      box-shadow: 0 12px 35px rgba(212, 175, 55, 0.7);
    }

    .start-buttons button.play-pvp {
      background: linear-gradient(135deg, #4a90e2, #6ba3f0);
      color: #fff;
      box-shadow: 0 6px 20px rgba(74, 144, 226, 0.5);
    }

    .start-buttons button.play-pvp:hover {
      box-shadow: 0 12px 35px rgba(74, 144, 226, 0.7);
      background: linear-gradient(135deg, #5ba0f2, #7bb3ff);
    }

    .start-buttons button.logout {
      background: rgba(255, 255, 255, 0.12);
      color: #fff;
      border: 2px solid rgba(212, 175, 55, 0.3);
      margin-top: 12px;
    }

    .start-buttons button.logout:hover {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(212, 175, 55, 0.5);
    }

    /* Waiting Room Overlay */
    #waitingRoomOverlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      max-width: 100vw;
      max-height: 100vh;
      background: radial-gradient(ellipse at 50% 50%, #2d1b4e 0%, #1a0f2e 40%, #05060d 100%);
      z-index: 998;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    #waitingRoomOverlay::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(212, 175, 55, 0.12) 0%, transparent 70%);
      animation: rotate 30s linear infinite;
      pointer-events: none;
    }

    #waitingRoomOverlay.hidden {
      display: none;
    }

    #waitingRoomPanel {
      background: linear-gradient(145deg, rgba(20, 15, 35, 0.98), rgba(10, 8, 20, 0.98));
      border: 2px solid rgba(212, 175, 55, 0.4);
      border-radius: 24px;
      padding: 50px 45px;
      max-width: 520px;
      width: 90%;
      box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 50px rgba(212, 175, 55, 0.25), inset 0 0 30px rgba(212, 175, 55, 0.08);
      backdrop-filter: blur(12px);
      text-align: center;
      position: relative;
      z-index: 1;
      animation: fadeInUp 0.6s ease-out;
    }

    #waitingRoomPanel::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      right: -2px;
      bottom: -2px;
      background: linear-gradient(45deg, rgba(212, 175, 55, 0.4), rgba(139, 69, 19, 0.4), rgba(212, 175, 55, 0.4));
      border-radius: 24px;
      z-index: -1;
      opacity: 0.7;
      animation: shimmer 4s ease-in-out infinite;
    }

    #waitingRoomPanel h2 {
      margin: 0 0 32px 0;
      font-size: 2rem;
      text-transform: uppercase;
      letter-spacing: 0.15em;
      background: linear-gradient(135deg, #d4af37, #f4e4bc, #d4af37);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      background-size: 200% auto;
      animation: gradientShift 3s ease infinite;
      font-weight: 700;
    }

    .waiting-status {
      padding: 28px 24px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 16px;
      margin: 24px 0;
      border: 2px solid rgba(212, 175, 55, 0.2);
      position: relative;
      overflow: hidden;
    }

    .waiting-status::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(212, 175, 55, 0.1) 0%, transparent 70%);
      animation: rotate 15s linear infinite;
      pointer-events: none;
    }

    .waiting-status p {
      position: relative;
      z-index: 1;
      font-size: 1.1rem;
      color: rgba(255, 255, 255, 0.95);
      margin: 0;
    }

    .waiting-status p:first-child {
      font-weight: 600;
      margin-bottom: 16px;
    }

    .waiting-status p:first-child::after {
      content: '...';
      animation: dots 1.5s steps(4, end) infinite;
    }

    @keyframes dots {
      0%, 20% { content: '.'; }
      40% { content: '..'; }
      60%, 100% { content: '...'; }
    }

    .match-found {
      background: rgba(74, 222, 128, 0.2);
      border: 2px solid #4ade80;
      box-shadow: 0 0 30px rgba(74, 222, 128, 0.4);
      animation: pulse 2s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { box-shadow: 0 0 30px rgba(74, 222, 128, 0.4); }
      50% { box-shadow: 0 0 50px rgba(74, 222, 128, 0.7); }
    }

    .waiting-buttons {
      display: flex;
      gap: 14px;
      margin-top: 28px;
    }

    .waiting-buttons button {
      flex: 1;
      padding: 16px 20px;
      border: none;
      border-radius: 12px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 1rem;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      position: relative;
      overflow: hidden;
    }

    .waiting-buttons button::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0;
      height: 0;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.3);
      transform: translate(-50%, -50%);
      transition: width 0.6s, height 0.6s;
    }

    .waiting-buttons button:hover::before {
      width: 300px;
      height: 300px;
    }

    .waiting-buttons button:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }

    .waiting-buttons button:active {
      transform: translateY(0);
    }

    .waiting-buttons button.accept {
      background: linear-gradient(135deg, #4ade80, #6ee7b7);
      color: #000;
      min-height: 48px;
      box-shadow: 0 4px 15px rgba(74, 222, 128, 0.4);
      z-index: 1;
      position: relative;
    }

    .waiting-buttons button.accept:hover {
      box-shadow: 0 8px 25px rgba(74, 222, 128, 0.6);
    }

    .waiting-buttons button.decline {
      background: linear-gradient(135deg, #f87171, #fb9a9a);
      color: #fff;
      min-height: 48px;
      box-shadow: 0 4px 15px rgba(248, 113, 113, 0.4);
      z-index: 1;
      position: relative;
    }

    .waiting-buttons button.decline:hover {
      box-shadow: 0 8px 25px rgba(248, 113, 113, 0.6);
    }

    .waiting-buttons button.cancel {
      background: rgba(255, 255, 255, 0.12);
      color: #fff;
      border: 2px solid rgba(212, 175, 55, 0.3);
      min-height: 48px;
    }

    .waiting-buttons button.cancel:hover {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(212, 175, 55, 0.5);
    }

    /* Mobile Landscape - Waiting Room */
    @media (orientation: landscape) and (max-height: 600px) {
      #waitingRoomPanel {
        padding: clamp(16px, 3vh, 28px) clamp(20px, 4vw, 35px);
        max-width: 85vw;
        max-height: 92vh;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: clamp(16px, 3vh, 24px);
        -webkit-overflow-scrolling: touch;
      }

      #waitingRoomPanel h2 {
        font-size: clamp(1.4rem, 5vh, 2rem);
        margin: 0 0 clamp(16px, 3vh, 24px) 0;
        letter-spacing: clamp(0.1em, 0.4vw, 0.15em);
      }

      .waiting-status {
        padding: clamp(16px, 3vh, 22px) clamp(18px, 4vw, 20px);
        border-radius: clamp(10px, 2vh, 16px);
        margin: clamp(16px, 3vh, 20px) 0;
      }

      .waiting-status p {
        font-size: clamp(0.95rem, 2.8vh, 1.1rem);
      }

      .waiting-status p:first-child {
        margin-bottom: clamp(10px, 2vh, 14px);
      }

      .waiting-buttons {
        gap: clamp(10px, 2vw, 14px);
        margin-top: clamp(16px, 3vh, 24px);
      }

      .waiting-buttons button {
        padding: clamp(12px, 2.5vh, 14px) clamp(16px, 3vw, 18px);
        font-size: clamp(0.9rem, 2.5vh, 1rem);
        border-radius: clamp(10px, 2vh, 12px);
        min-height: clamp(40px, 8vh, 48px);
      }
    }

    /* Mobile Portrait */
    @media (max-width: 768px) and (orientation: portrait) {
      #authPanel, #startScreenPanel, #waitingRoomPanel {
        padding: 24px;
        max-height: 90vh;
        overflow-y: auto;
      }
      
      .waiting-buttons {
        flex-direction: column;
        gap: 10px;
      }
      
      .waiting-buttons button {
        width: 100%;
        min-height: 48px; /* Larger touch target on mobile */
        font-size: 1.1rem;
        padding: 14px;
      }
      
      .waiting-buttons button.accept,
      .waiting-buttons button.decline {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
      }
    }
