/* ════════════════════════════════════════════════════════════════════
   TypeArena — UI ELEMENTS REFINED v5
   Все UI элементы переделаны красиво для мобильных
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* ─────── INPUT FIELDS ─────── */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    width: 100%;
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    border: 2px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    border-radius: 10px;
    font-family: inherit;
    transition: all 0.2s;
  }

  input:focus,
  textarea:focus,
  select:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
  }

  input::placeholder {
    color: var(--text2);
    font-weight: 500;
  }

  /* ─────── PRIMARY BUTTONS ─────── */
  .btn-primary,
  button.primary,
  .primary-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent), rgba(88, 166, 255, 0.7));
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-primary:active,
  button.primary:active,
  .primary-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(88, 166, 255, 0.4);
  }

  .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }

  /* ─────── SECONDARY BUTTONS ─────── */
  .btn-secondary,
  button.secondary,
  .secondary-btn {
    padding: 12px 24px;
    background: var(--bg2);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-secondary:active,
  button.secondary:active,
  .secondary-btn:active {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
  }

  /* ─────── TERTIARY BUTTONS ─────── */
  .btn-tertiary,
  button.tertiary,
  .tertiary-btn {
    padding: 10px 16px;
    background: transparent;
    color: var(--accent);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-tertiary:active,
  button.tertiary:active,
  .tertiary-btn:active {
    background: rgba(88, 166, 255, 0.1);
  }

  /* ─────── ICON BUTTONS ─────── */
  .icon-btn,
  button.icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .icon-btn:active,
  button.icon:active {
    transform: scale(0.9);
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
  }

  /* ─────── SWITCH / TOGGLE ─────── */
  .toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--bg3);
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
  }

  .toggle-switch::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  .toggle-switch.active {
    background: var(--accent);
  }

  .toggle-switch.active::after {
    left: 26px;
  }

  /* ─────── CHECKBOX ─────── */
  input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
  }

  input[type="checkbox"]:hover {
    transform: scale(1.1);
  }

  /* ─────── RADIO BUTTONS ─────── */
  input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
  }

  /* ─────── SELECT / DROPDOWN ─────── */
  select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2358a6ff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 36px;
    background-size: 20px;
  }

  /* ─────── FORM GROUP ─────── */
  .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
  }

  .form-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
  }

  .form-hint {
    font-size: 0.75rem;
    color: var(--text2);
    font-weight: 500;
  }

  .form-error {
    font-size: 0.75rem;
    color: #ff6464;
    font-weight: 600;
  }

  /* ─────── SEGMENTED CONTROL ─────── */
  .segmented-control {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg2);
    border-radius: 8px;
  }

  .segment-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
  }

  .segment-btn.active {
    background: var(--bg);
    color: var(--accent);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  /* ─────── TABS ─────── */
  .tabs-container {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 16px;
  }

  .tab-btn {
    padding: 12px 0;
    background: none;
    border: none;
    color: var(--text2);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
  }

  .tab-btn:hover {
    color: var(--text);
  }

  .tab-btn.active {
    color: var(--accent);
  }

  .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
  }

  /* ─────── CHIP / TAG ─────── */
  .chip,
  .tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(88, 166, 255, 0.15);
    border: 1px solid rgba(88, 166, 255, 0.3);
    color: var(--accent);
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
  }

  .chip.removable {
    padding-right: 6px;
  }

  .chip-close {
    background: none;
    border: none;
    padding: 4px;
    color: var(--accent);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ─────── LISTS ─────── */
  .list-item {
    padding: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
  }

  .list-item:active {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
  }

  .list-item-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
  }

  .list-item-content {
    flex: 1;
    min-width: 0;
  }

  .list-item-title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
  }

  .list-item-subtitle {
    font-size: 0.8rem;
    color: var(--text2);
  }

  .list-item-action {
    flex-shrink: 0;
  }

  /* ─────── ACCORDION ─────── */
  .accordion-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
  }

  .accordion-header {
    padding: 12px;
    background: var(--bg2);
    border: none;
    width: 100%;
    text-align: left;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.2s;
  }

  .accordion-header:active {
    background: rgba(88, 166, 255, 0.08);
  }

  .accordion-icon {
    font-size: 1.2rem;
    transition: transform 0.2s;
  }

  .accordion-item.open .accordion-icon {
    transform: rotate(180deg);
  }

  .accordion-content {
    padding: 12px;
    background: var(--bg);
    display: none;
  }

  .accordion-item.open .accordion-content {
    display: block;
  }

  /* ─────── DIVIDER ─────── */
  .divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--border) 20%, var(--border) 80%, transparent 100%);
    margin: 16px 0;
  }

  /* ─────── EMPTY STATE IMPROVED ─────── */
  .empty-state {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .empty-state-icon {
    font-size: 3.5rem;
    opacity: 0.6;
  }

  .empty-state-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
  }

  .empty-state-desc {
    font-size: 0.9rem;
    color: var(--text2);
    max-width: 280px;
    line-height: 1.5;
  }

  /* ─────── BREADCRUMB ─────── */
  .breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    font-size: 0.85rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .breadcrumb-item {
    color: var(--text2);
    white-space: nowrap;
  }

  .breadcrumb-item.active {
    color: var(--accent);
    font-weight: 700;
  }

  .breadcrumb-separator {
    color: var(--text2);
    margin: 0 4px;
  }

  /* ─────── PAGINATION ─────── */
  .pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 16px 0;
  }

  .pagination-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg2);
    border-radius: 6px;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
  }

  .pagination-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  .pagination-btn:active {
    transform: scale(0.95);
  }

  /* ─────── STEPPER ─────── */
  .stepper {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .stepper-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text2);
  }

  .stepper-step.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  .stepper-step.completed {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border-color: #4ade80;
  }

  .stepper-line {
    flex: 1;
    height: 2px;
    background: var(--border);
  }

  /* ─────── RATINGS / STARS ─────── */
  .star-rating {
    display: flex;
    gap: 4px;
  }

  .star {
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text2);
    transition: all 0.2s;
  }

  .star.active,
  .star.hover {
    color: #ffc832;
  }

  /* ─────── ANIMATIONS FOR LOW GRAPHICS ─────── */
  body[data-graphics="low"] button,
  body[data-graphics="low"] input,
  body[data-graphics="low"] .tab-btn {
    transition: none;
  }

  body[data-graphics="low"] .toggle-switch,
  body[data-graphics="low"] .toggle-switch::after {
    transition: none;
  }

  body[data-graphics="low"] .segment-btn.active {
    box-shadow: none;
  }

  body[data-graphics="low"] input:focus {
    box-shadow: none;
  }

  /* ─────── RESPONSIVE ADJUSTMENTS ─────── */
  @media (max-width: 480px) {
    .btn-primary,
    .btn-secondary,
    button.primary,
    button.secondary {
      width: 100%;
    }

    .tabs-container {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    .pagination {
      flex-wrap: wrap;
    }
  }
}
