/* ==========================================================
   TIC TAC TOE - Mobile-First CSS
   ========================================================== */

.ttt-app {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Card container */
.ttt-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

/* Title */
.ttt-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px;
  color: #1a1a1a;
  letter-spacing: -0.02em;
}

/* Row layout */
.ttt-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.ttt-btn {
  flex: 1 1 120px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ttt-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
  border-color: rgba(0, 0, 0, 0.15);
}

.ttt-btn:active {
  transform: scale(0.97);
  background: #e8e8e8;
}

.ttt-btn--primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #ffffff;
}

.ttt-btn--primary:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
}

.ttt-btn--small {
  flex: 0 0 auto;
  padding: 10px 16px;
  font-size: 14px;
}

/* Meta text */
.ttt-meta {
  margin-top: 14px;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.ttt-meta strong {
  color: #1a1a1a;
  font-weight: 600;
}

/* Input */
.ttt-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fafafa;
  font-size: 16px;
  font-family: inherit;
  color: #1a1a1a;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.ttt-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ttt-input::placeholder {
  color: #999;
}

/* Board */
.ttt-board {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ttt-cell {
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
  font-size: 48px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.12s ease;
  color: #1a1a1a;
}

.ttt-cell:hover:not(.ttt-cell--disabled) {
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  border-color: rgba(0, 0, 0, 0.15);
}

.ttt-cell:active:not(.ttt-cell--disabled) {
  transform: scale(0.95);
}

.ttt-cell--disabled {
  cursor: not-allowed;
}

.ttt-cell--x {
  color: #3b82f6;
}

.ttt-cell--o {
  color: #ef4444;
}

.ttt-cell--winner {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: #22c55e;
}

/* Status badge */
.ttt-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
}

.ttt-status--waiting {
  background: #fef3c7;
  color: #92400e;
}

.ttt-status--playing {
  background: #dbeafe;
  color: #1e40af;
}

.ttt-status--finished {
  background: #dcfce7;
  color: #166534;
}

.ttt-status--error {
  background: #fee2e2;
  color: #991b1b;
}

/* Pulse animation for waiting */
.ttt-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: ttt-pulse-anim 1.5s ease-in-out infinite;
}

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

/* Room code display */
.ttt-room-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  background: #f0f9ff;
  border-radius: 14px;
  border: 1px dashed #3b82f6;
}

.ttt-room-code__value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #1e40af;
  font-family: "SF Mono", "Fira Code", monospace;
}

.ttt-room-code__copy {
  padding: 8px 12px;
  font-size: 13px;
}

/* Link share */
.ttt-share-link {
  margin-top: 12px;
  padding: 12px;
  background: #fafafa;
  border-radius: 10px;
  font-size: 13px;
  color: #666;
  word-break: break-all;
}

/* Divider */
.ttt-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #999;
  font-size: 13px;
}

.ttt-divider::before,
.ttt-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
}

/* Loading spinner */
.ttt-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ttt-spin 0.75s linear infinite;
}

@keyframes ttt-spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (min-width: 480px) {
  .ttt-app {
    padding: 24px;
  }
  
  .ttt-card {
    padding: 28px;
  }
  
  .ttt-title {
    font-size: 26px;
  }
  
  .ttt-cell {
    font-size: 56px;
  }
  
  .ttt-board {
    gap: 12px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ttt-card {
    background: #1f1f1f;
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .ttt-title {
    color: #ffffff;
  }
  
  .ttt-btn {
    background: linear-gradient(180deg, #2a2a2a 0%, #222222 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
  }
  
  .ttt-btn:hover {
    background: linear-gradient(180deg, #333333 0%, #2a2a2a 100%);
  }
  
  .ttt-input {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
  }
  
  .ttt-input:focus {
    background: #333333;
  }
  
  .ttt-cell {
    background: linear-gradient(180deg, #2a2a2a 0%, #222222 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
  }
  
  .ttt-meta {
    color: #aaa;
  }
  
  .ttt-meta strong {
    color: #ffffff;
  }
  
  .ttt-room-code {
    background: #1e3a5f;
    border-color: #3b82f6;
  }
  
  .ttt-room-code__value {
    color: #93c5fd;
  }
}
