:root {
  --primary: #4361ee;
  --primary-dark: #3651d4;
  --secondary: #7209b7;
  --success: #06d6a0;
  --danger: #ef476f;
  --warning: #ffd166;
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --text: #edf2f4;
  --text-light: #8d99ae;
  --border: #2b4162;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px var(--shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.header h1 {
  font-size: 1.4em;
  font-weight: 700;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85em;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s infinite;
}

.status-dot.connected {
  background: var(--success);
  animation: none;
}

.status-dot.disconnected {
  background: var(--danger);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main */
.main {
  flex: 1;
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.section {
  animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
  text-align: center;
  border: 1px solid var(--border);
}

.card-icon {
  font-size: 3em;
  margin-bottom: 16px;
}

.card h2 {
  margin-bottom: 12px;
  font-size: 1.3em;
}

.card p {
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.6;
}

.hint {
  font-size: 0.85em;
  color: var(--text-light);
  margin-top: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-icon {
  font-size: 1.2em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 1.1em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Waiting Card */
.waiting-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  border: 1px solid var(--border);
}

.pulse-animation {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
}

.pulse-circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.2;
  animation: pulseCircle 2s infinite;
}

@keyframes pulseCircle {
  0% { transform: scale(0.8); opacity: 0.2; }
  50% { transform: scale(1.2); opacity: 0.1; }
  100% { transform: scale(0.8); opacity: 0.2; }
}

.pulse-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3em;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2em;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85em;
  color: var(--text-light);
}

/* Interaction Card */
.interaction-card {
  background: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.interaction-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 20px;
  text-align: center;
}

.interaction-icon {
  font-size: 2.5em;
  display: block;
  margin-bottom: 8px;
}

.interaction-body {
  padding: 24px;
}

.captcha-container {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.captcha-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.captcha-container .btn-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--bg-card);
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}

.interaction-description {
  color: var(--text-light);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Inputs */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9em;
  color: var(--text-light);
}

.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.1em;
  font-family: inherit;
  text-align: center;
  transition: border-color 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-light);
  opacity: 0.7;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row .input-group {
  flex: 1;
}

/* Card Form */
.card-form {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-form .input {
  text-align: right;
  direction: ltr;
}

/* Footer */
.interaction-footer {
  padding: 20px 24px;
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.interaction-footer .btn-primary {
  flex: 2;
}

.interaction-footer .btn-danger {
  flex: 1;
}

/* Timer */
.timer {
  padding: 16px 24px;
  text-align: center;
  background: var(--bg-dark);
}

#timer-value {
  font-size: 1.5em;
  font-weight: 700;
  font-family: monospace;
}

.timer-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.timer-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--primary));
  width: 100%;
  transition: width 1s linear;
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-light);
  font-size: 0.85em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text);
  padding: 14px 24px;
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow);
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  border: 1px solid var(--border);
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

/* Responsive */
@media (max-width: 400px) {
  .header h1 {
    font-size: 1.2em;
  }
  
  .stats {
    gap: 24px;
  }
  
  .stat-value {
    font-size: 1.5em;
  }
}
